From e319fce63d7040e99e5073120ea7a9cce2272f3c Mon Sep 17 00:00:00 2001
From: jbrandin <42254097+jbrandin@users.noreply.github.com>
Date: Mon, 4 Mar 2019 14:50:44 -0600
Subject: [PATCH 1/3] Add KilogramPerLiter DensityUnit
---
Common/UnitDefinitions/Density.json | 12 ++++++++++++
UnitsNet.Tests/CustomCode/DensityTests.cs | 3 +++
.../Density.WindowsRuntimeComponent.g.cs | 17 +++++++++++++++++
.../GeneratedCode/UnitAbbreviationsCache.g.cs | 1 +
.../GeneratedCode/Units/DensityUnit.g.cs | 1 +
.../Quantities/Density.NetFramework.g.cs | 17 +++++++++++++++++
.../GeneratedCode/UnitAbbreviationsCache.g.cs | 1 +
UnitsNet/GeneratedCode/Units/DensityUnit.g.cs | 1 +
8 files changed, 53 insertions(+)
diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json
index 34dc703759..12cd532161 100644
--- a/Common/UnitDefinitions/Density.json
+++ b/Common/UnitDefinitions/Density.json
@@ -189,6 +189,18 @@
"Abbreviations": [ "ppg (imp.)" ]
}
]
+ },
+ {
+ "SingularName": "KilogramPerLiter",
+ "PluralName": "KilogramsPerLiter",
+ "FromUnitToBaseFunc": "x*1e3",
+ "FromBaseToUnitFunc": "x/1e3",
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "kg/l" ]
+ }
+ ]
}
]
}
\ No newline at end of file
diff --git a/UnitsNet.Tests/CustomCode/DensityTests.cs b/UnitsNet.Tests/CustomCode/DensityTests.cs
index 8fb4b14e74..9dabe74215 100644
--- a/UnitsNet.Tests/CustomCode/DensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/DensityTests.cs
@@ -30,6 +30,7 @@ public class DensityTests : DensityTestsBase
protected override double PoundsPerCubicInchInOneKilogramPerCubicMeter => 3.61272923e-5;
protected override double PoundsPerUSGallonInOneKilogramPerCubicMeter => 8.3454045e-3;
+
protected override double PoundsPerImperialGallonInOneKilogramPerCubicMeter => 1.002241e-2;
protected override double TonnesPerCubicCentimeterInOneKilogramPerCubicMeter => 1e-9;
@@ -84,6 +85,8 @@ public class DensityTests : DensityTestsBase
protected override double MicrogramsPerCubicMeterInOneKilogramPerCubicMeter => 1e9;
+ protected override double KilogramsPerLiterInOneKilogramPerCubicMeter => 1e-3;
+
[Fact]
public static void DensityTimesVolumeEqualsMass()
{
diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs
index 1e58c0401c..ec7ef50056 100644
--- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs
+++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs
@@ -233,6 +233,11 @@ private Density(double numericValue, DensityUnit unit)
///
public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter);
+ ///
+ /// Get Density in KilogramsPerLiter.
+ ///
+ public double KilogramsPerLiter => As(DensityUnit.KilogramPerLiter);
+
///
/// Get Density in KilopoundsPerCubicFoot.
///
@@ -534,6 +539,16 @@ public static Density FromKilogramsPerCubicMillimeter(double kilogramspercubicmi
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.
@@ -1079,6 +1094,7 @@ private double AsBaseUnit()
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;
@@ -1132,6 +1148,7 @@ private double AsBaseNumericType(DensityUnit unit)
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;
diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs
index 42cb1dfcf4..8133129dc3 100644
--- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs
+++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs
@@ -180,6 +180,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
("en-US", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicMeter, new string[]{"kg/m³"}),
("ru-RU", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicMeter, new string[]{"kг/м³"}),
("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³"}),
diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs
index 97ecf5c6aa..80636ee0c9 100644
--- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs
+++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs
@@ -41,6 +41,7 @@ public enum DensityUnit
KilogramPerCubicCentimeter,
KilogramPerCubicMeter,
KilogramPerCubicMillimeter,
+ KilogramPerLiter,
KilopoundPerCubicFoot,
KilopoundPerCubicInch,
MicrogramPerCubicMeter,
diff --git a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs
index 2bc80035f6..4f53345b20 100644
--- a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs
@@ -68,6 +68,7 @@ static Density()
new UnitInfo(DensityUnit.KilogramPerCubicCentimeter, BaseUnits.Undefined),
new UnitInfo(DensityUnit.KilogramPerCubicMeter, BaseUnits.Undefined),
new UnitInfo(DensityUnit.KilogramPerCubicMillimeter, BaseUnits.Undefined),
+ new UnitInfo(DensityUnit.KilogramPerLiter, BaseUnits.Undefined),
new UnitInfo(DensityUnit.KilopoundPerCubicFoot, BaseUnits.Undefined),
new UnitInfo(DensityUnit.KilopoundPerCubicInch, BaseUnits.Undefined),
new UnitInfo(DensityUnit.MicrogramPerCubicMeter, BaseUnits.Undefined),
@@ -276,6 +277,11 @@ public Density(double numericValue, UnitSystem unitSystem)
///
public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter);
+ ///
+ /// Get Density in KilogramsPerLiter.
+ ///
+ public double KilogramsPerLiter => As(DensityUnit.KilogramPerLiter);
+
///
/// Get Density in KilopoundsPerCubicFoot.
///
@@ -561,6 +567,15 @@ public static Density FromKilogramsPerCubicMillimeter(QuantityValue kilogramsper
return new Density(value, DensityUnit.KilogramPerCubicMillimeter);
}
///
+ /// Get Density from KilogramsPerLiter.
+ ///
+ /// If value is NaN or Infinity.
+ public static Density FromKilogramsPerLiter(QuantityValue kilogramsperliter)
+ {
+ double value = (double) kilogramsperliter;
+ return new Density(value, DensityUnit.KilogramPerLiter);
+ }
+ ///
/// Get Density from KilopoundsPerCubicFoot.
///
/// If value is NaN or Infinity.
@@ -1210,6 +1225,7 @@ private double GetValueInBaseUnit()
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;
@@ -1263,6 +1279,7 @@ private double GetValueAs(DensityUnit unit)
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;
diff --git a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs
index 8870c3e2d8..9018fb5310 100644
--- a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs
+++ b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs
@@ -180,6 +180,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
("en-US", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicMeter, new string[]{"kg/m³"}),
("ru-RU", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicMeter, new string[]{"kг/м³"}),
("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³"}),
diff --git a/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs
index 97ecf5c6aa..80636ee0c9 100644
--- a/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs
+++ b/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs
@@ -41,6 +41,7 @@ public enum DensityUnit
KilogramPerCubicCentimeter,
KilogramPerCubicMeter,
KilogramPerCubicMillimeter,
+ KilogramPerLiter,
KilopoundPerCubicFoot,
KilopoundPerCubicInch,
MicrogramPerCubicMeter,
From 6058abafb65fd6457f71894784630aa8f0b648eb Mon Sep 17 00:00:00 2001
From: jbrandin <42254097+jbrandin@users.noreply.github.com>
Date: Mon, 4 Mar 2019 16:07:05 -0600
Subject: [PATCH 2/3] Update Common/UnitDefinitions/Density.json with BaseUnits
---
Common/UnitDefinitions/Density.json | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json
index 12cd532161..e6e24ccfda 100644
--- a/Common/UnitDefinitions/Density.json
+++ b/Common/UnitDefinitions/Density.json
@@ -193,6 +193,10 @@
{
"SingularName": "KilogramPerLiter",
"PluralName": "KilogramsPerLiter",
+ "BaseUnits": {
+ "L": "Decimeter",
+ "M": "Kilogram"
+ },
"FromUnitToBaseFunc": "x*1e3",
"FromBaseToUnitFunc": "x/1e3",
"Localization": [
@@ -203,4 +207,4 @@
]
}
]
-}
\ No newline at end of file
+}
From 37fa728cbc363f1d7e5a374b03eee327cf5a7c0b Mon Sep 17 00:00:00 2001
From: jbrandin <42254097+jbrandin@users.noreply.github.com>
Date: Mon, 4 Mar 2019 16:18:13 -0600
Subject: [PATCH 3/3] Update Common/UnitDefinitions/Density.json with BaseUnits
---
Common/UnitDefinitions/Density.json | 4 ++++
UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json
index 12cd532161..74285eaebc 100644
--- a/Common/UnitDefinitions/Density.json
+++ b/Common/UnitDefinitions/Density.json
@@ -193,6 +193,10 @@
{
"SingularName": "KilogramPerLiter",
"PluralName": "KilogramsPerLiter",
+ "BaseUnits": {
+ "L": "Decimeter",
+ "M": "Kilogram"
+ },
"FromUnitToBaseFunc": "x*1e3",
"FromBaseToUnitFunc": "x/1e3",
"Localization": [
diff --git a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs
index 4f53345b20..48f1d67c14 100644
--- a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs
@@ -68,7 +68,7 @@ static Density()
new UnitInfo(DensityUnit.KilogramPerCubicCentimeter, BaseUnits.Undefined),
new UnitInfo(DensityUnit.KilogramPerCubicMeter, BaseUnits.Undefined),
new UnitInfo(DensityUnit.KilogramPerCubicMillimeter, BaseUnits.Undefined),
- new UnitInfo(DensityUnit.KilogramPerLiter, BaseUnits.Undefined),
+ new UnitInfo(DensityUnit.KilogramPerLiter, new BaseUnits(length: LengthUnit.Decimeter, mass: MassUnit.Kilogram)),
new UnitInfo(DensityUnit.KilopoundPerCubicFoot, BaseUnits.Undefined),
new UnitInfo(DensityUnit.KilopoundPerCubicInch, BaseUnits.Undefined),
new UnitInfo(DensityUnit.MicrogramPerCubicMeter, BaseUnits.Undefined),