diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json
index 34dc703759..e6e24ccfda 100644
--- a/Common/UnitDefinitions/Density.json
+++ b/Common/UnitDefinitions/Density.json
@@ -189,6 +189,22 @@
"Abbreviations": [ "ppg (imp.)" ]
}
]
+ },
+ {
+ "SingularName": "KilogramPerLiter",
+ "PluralName": "KilogramsPerLiter",
+ "BaseUnits": {
+ "L": "Decimeter",
+ "M": "Kilogram"
+ },
+ "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..48f1d67c14 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, 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),
@@ -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,