diff --git a/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs
new file mode 100644
index 0000000000..3f32c35919
--- /dev/null
+++ b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated (once) by \generate-code.bat, but will not be
+// regenerated when it already exists. The purpose of creating this file is to make
+// it easier to remember to implement all the unit conversion test cases.
+//
+// Whenever a new unit is added to this quantity and \generate-code.bat is run,
+// the base test class will get a new abstract property and cause a compile error
+// in this derived class, reminding the developer to implement the test case
+// for the new unit.
+//
+// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (angularsen@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+namespace UnitsNet.Tests.CustomCode
+{
+ public class AmountOfSubstanceTests : AmountOfSubstanceTestsBase
+ {
+ protected override double CentimolesInOneMole => 1e2;
+ protected override double CentipoundMolesInOneMole => 0.002204622621848776 * 1e2;
+ protected override double DecimolesInOneMole => 1e1;
+ protected override double DecipoundMolesInOneMole => 0.002204622621848776 * 1e1;
+ protected override double KilomolesInOneMole => 1e-3;
+ protected override double KilopoundMolesInOneMole => 0.002204622621848776 * 1e-3;
+ protected override double MicromolesInOneMole => 1e6;
+ protected override double MicropoundMolesInOneMole => 0.002204622621848776 * 1e6;
+ protected override double MillimolesInOneMole => 1e3;
+ protected override double MillipoundMolesInOneMole => 0.002204622621848776 * 1e3;
+ protected override double MolesInOneMole => 1;
+ protected override double NanomolesInOneMole => 1e9;
+ protected override double NanopoundMolesInOneMole => 0.002204622621848776 * 1e9;
+ protected override double PoundMolesInOneMole => 0.002204622621848776;
+ }
+}
diff --git a/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
new file mode 100644
index 0000000000..82f45036ae
--- /dev/null
+++ b/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
@@ -0,0 +1,257 @@
+//------------------------------------------------------------------------------
+//
+// 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\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (angularsen@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using UnitsNet.Units;
+using Xunit;
+
+// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else?
+#pragma warning disable 1718
+
+// ReSharper disable once CheckNamespace
+namespace UnitsNet.Tests
+{
+ ///
+ /// Test of AmountOfSubstance.
+ ///
+// ReSharper disable once PartialTypeWithSinglePart
+ public abstract partial class AmountOfSubstanceTestsBase
+ {
+ protected abstract double CentimolesInOneMole { get; }
+ protected abstract double CentipoundMolesInOneMole { get; }
+ protected abstract double DecimolesInOneMole { get; }
+ protected abstract double DecipoundMolesInOneMole { get; }
+ protected abstract double KilomolesInOneMole { get; }
+ protected abstract double KilopoundMolesInOneMole { get; }
+ protected abstract double MicromolesInOneMole { get; }
+ protected abstract double MicropoundMolesInOneMole { get; }
+ protected abstract double MillimolesInOneMole { get; }
+ protected abstract double MillipoundMolesInOneMole { get; }
+ protected abstract double MolesInOneMole { get; }
+ protected abstract double NanomolesInOneMole { get; }
+ protected abstract double NanopoundMolesInOneMole { get; }
+ 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 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
+
+ [Fact]
+ public void MoleToAmountOfSubstanceUnits()
+ {
+ AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
+ AssertEx.EqualTolerance(CentimolesInOneMole, mole.Centimoles, CentimolesTolerance);
+ AssertEx.EqualTolerance(CentipoundMolesInOneMole, mole.CentipoundMoles, CentipoundMolesTolerance);
+ AssertEx.EqualTolerance(DecimolesInOneMole, mole.Decimoles, DecimolesTolerance);
+ AssertEx.EqualTolerance(DecipoundMolesInOneMole, mole.DecipoundMoles, DecipoundMolesTolerance);
+ AssertEx.EqualTolerance(KilomolesInOneMole, mole.Kilomoles, KilomolesTolerance);
+ AssertEx.EqualTolerance(KilopoundMolesInOneMole, mole.KilopoundMoles, KilopoundMolesTolerance);
+ AssertEx.EqualTolerance(MicromolesInOneMole, mole.Micromoles, MicromolesTolerance);
+ AssertEx.EqualTolerance(MicropoundMolesInOneMole, mole.MicropoundMoles, MicropoundMolesTolerance);
+ AssertEx.EqualTolerance(MillimolesInOneMole, mole.Millimoles, MillimolesTolerance);
+ AssertEx.EqualTolerance(MillipoundMolesInOneMole, mole.MillipoundMoles, MillipoundMolesTolerance);
+ AssertEx.EqualTolerance(MolesInOneMole, mole.Moles, MolesTolerance);
+ AssertEx.EqualTolerance(NanomolesInOneMole, mole.Nanomoles, NanomolesTolerance);
+ AssertEx.EqualTolerance(NanopoundMolesInOneMole, mole.NanopoundMoles, NanopoundMolesTolerance);
+ AssertEx.EqualTolerance(PoundMolesInOneMole, mole.PoundMoles, PoundMolesTolerance);
+ }
+
+ [Fact]
+ public void FromValueAndUnit()
+ {
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Centimole).Centimoles, CentimolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.CentipoundMole).CentipoundMoles, CentipoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Decimole).Decimoles, DecimolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.DecipoundMole).DecipoundMoles, DecipoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Kilomole).Kilomoles, KilomolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.KilopoundMole).KilopoundMoles, KilopoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Micromole).Micromoles, MicromolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.MicropoundMole).MicropoundMoles, MicropoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Millimole).Millimoles, MillimolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.MillipoundMole).MillipoundMoles, MillipoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Mole).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Nanomole).Nanomoles, NanomolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.NanopoundMole).NanopoundMoles, NanopoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.PoundMole).PoundMoles, PoundMolesTolerance);
+ }
+
+ [Fact]
+ public void As()
+ {
+ var mole = AmountOfSubstance.FromMoles(1);
+ AssertEx.EqualTolerance(CentimolesInOneMole, mole.As(AmountOfSubstanceUnit.Centimole), CentimolesTolerance);
+ AssertEx.EqualTolerance(CentipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.CentipoundMole), CentipoundMolesTolerance);
+ AssertEx.EqualTolerance(DecimolesInOneMole, mole.As(AmountOfSubstanceUnit.Decimole), DecimolesTolerance);
+ AssertEx.EqualTolerance(DecipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.DecipoundMole), DecipoundMolesTolerance);
+ AssertEx.EqualTolerance(KilomolesInOneMole, mole.As(AmountOfSubstanceUnit.Kilomole), KilomolesTolerance);
+ AssertEx.EqualTolerance(KilopoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.KilopoundMole), KilopoundMolesTolerance);
+ AssertEx.EqualTolerance(MicromolesInOneMole, mole.As(AmountOfSubstanceUnit.Micromole), MicromolesTolerance);
+ AssertEx.EqualTolerance(MicropoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.MicropoundMole), MicropoundMolesTolerance);
+ AssertEx.EqualTolerance(MillimolesInOneMole, mole.As(AmountOfSubstanceUnit.Millimole), MillimolesTolerance);
+ AssertEx.EqualTolerance(MillipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.MillipoundMole), MillipoundMolesTolerance);
+ AssertEx.EqualTolerance(MolesInOneMole, mole.As(AmountOfSubstanceUnit.Mole), MolesTolerance);
+ AssertEx.EqualTolerance(NanomolesInOneMole, mole.As(AmountOfSubstanceUnit.Nanomole), NanomolesTolerance);
+ AssertEx.EqualTolerance(NanopoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.NanopoundMole), NanopoundMolesTolerance);
+ AssertEx.EqualTolerance(PoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.PoundMole), PoundMolesTolerance);
+ }
+
+ [Fact]
+ public void ConversionRoundTrip()
+ {
+ AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentimoles(mole.Centimoles).Moles, CentimolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentipoundMoles(mole.CentipoundMoles).Moles, CentipoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecimoles(mole.Decimoles).Moles, DecimolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecipoundMoles(mole.DecipoundMoles).Moles, DecipoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilomoles(mole.Kilomoles).Moles, KilomolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilopoundMoles(mole.KilopoundMoles).Moles, KilopoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicromoles(mole.Micromoles).Moles, MicromolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicropoundMoles(mole.MicropoundMoles).Moles, MicropoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillimoles(mole.Millimoles).Moles, MillimolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillipoundMoles(mole.MillipoundMoles).Moles, MillipoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromMoles(mole.Moles).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanomoles(mole.Nanomoles).Moles, NanomolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanopoundMoles(mole.NanopoundMoles).Moles, NanopoundMolesTolerance);
+ AssertEx.EqualTolerance(1, AmountOfSubstance.FromPoundMoles(mole.PoundMoles).Moles, PoundMolesTolerance);
+ }
+
+ [Fact]
+ public void ArithmeticOperators()
+ {
+ AmountOfSubstance v = AmountOfSubstance.FromMoles(1);
+ AssertEx.EqualTolerance(-1, -v.Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(3)-v).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, (v + v).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(10, (v*10).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(10, (10*v).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(10)/5).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, AmountOfSubstance.FromMoles(10)/AmountOfSubstance.FromMoles(5), MolesTolerance);
+ }
+
+ [Fact]
+ public void ComparisonOperators()
+ {
+ AmountOfSubstance oneMole = AmountOfSubstance.FromMoles(1);
+ AmountOfSubstance twoMoles = AmountOfSubstance.FromMoles(2);
+
+ Assert.True(oneMole < twoMoles);
+ Assert.True(oneMole <= twoMoles);
+ Assert.True(twoMoles > oneMole);
+ Assert.True(twoMoles >= oneMole);
+
+ Assert.False(oneMole > twoMoles);
+ Assert.False(oneMole >= twoMoles);
+ Assert.False(twoMoles < oneMole);
+ Assert.False(twoMoles <= oneMole);
+ }
+
+ [Fact]
+ public void CompareToIsImplemented()
+ {
+ AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
+ Assert.Equal(0, mole.CompareTo(mole));
+ Assert.True(mole.CompareTo(AmountOfSubstance.Zero) > 0);
+ Assert.True(AmountOfSubstance.Zero.CompareTo(mole) < 0);
+ }
+
+ [Fact]
+ public void CompareToThrowsOnTypeMismatch()
+ {
+ AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
+ Assert.Throws(() => mole.CompareTo(new object()));
+ }
+
+ [Fact]
+ public void CompareToThrowsOnNull()
+ {
+ AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
+ Assert.Throws(() => mole.CompareTo(null));
+ }
+
+
+ [Fact]
+ public void EqualityOperators()
+ {
+ AmountOfSubstance a = AmountOfSubstance.FromMoles(1);
+ AmountOfSubstance b = AmountOfSubstance.FromMoles(2);
+
+// ReSharper disable EqualExpressionComparison
+ Assert.True(a == a);
+ Assert.True(a != b);
+
+ Assert.False(a == b);
+ Assert.False(a != a);
+// ReSharper restore EqualExpressionComparison
+ }
+
+ [Fact]
+ public void EqualsIsImplemented()
+ {
+ AmountOfSubstance v = AmountOfSubstance.FromMoles(1);
+ Assert.True(v.Equals(AmountOfSubstance.FromMoles(1)));
+ Assert.False(v.Equals(AmountOfSubstance.Zero));
+ }
+
+ [Fact]
+ public void EqualsReturnsFalseOnTypeMismatch()
+ {
+ AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
+ Assert.False(mole.Equals(new object()));
+ }
+
+ [Fact]
+ public void EqualsReturnsFalseOnNull()
+ {
+ AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
+ Assert.False(mole.Equals(null));
+ }
+ }
+}
diff --git a/UnitsNet.Tests/GeneratedCode/SubstanceAmountTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SubstanceAmountTestsBase.g.cs
new file mode 100644
index 0000000000..461c1dbdd9
--- /dev/null
+++ b/UnitsNet.Tests/GeneratedCode/SubstanceAmountTestsBase.g.cs
@@ -0,0 +1,215 @@
+//------------------------------------------------------------------------------
+//
+// 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/anjdreas/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\UnitClasses\MyUnit.extra.cs files to add code to generated unit classes.
+// Add Extensions\MyUnitExtensions.cs to decorate unit classes with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or unit classes.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (anjdreas@gmail.com).
+// https://github.com/anjdreas/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using UnitsNet.Units;
+using Xunit;
+
+// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else?
+#pragma warning disable 1718
+
+// ReSharper disable once CheckNamespace
+namespace UnitsNet.Tests
+{
+ ///
+ /// Test of SubstanceAmount.
+ ///
+// ReSharper disable once PartialTypeWithSinglePart
+ public abstract partial class SubstanceAmountTestsBase
+ {
+ protected abstract double CentimolesInOneMole { get; }
+ protected abstract double DecimolesInOneMole { get; }
+ protected abstract double KilomolesInOneMole { get; }
+ protected abstract double MicromolesInOneMole { get; }
+ protected abstract double MillimolesInOneMole { get; }
+ protected abstract double MolesInOneMole { get; }
+ protected abstract double NanomolesInOneMole { get; }
+
+// ReSharper disable VirtualMemberNeverOverriden.Global
+ protected virtual double CentimolesTolerance { get { return 1e-5; } }
+ protected virtual double DecimolesTolerance { get { return 1e-5; } }
+ protected virtual double KilomolesTolerance { get { return 1e-5; } }
+ protected virtual double MicromolesTolerance { get { return 1e-5; } }
+ protected virtual double MillimolesTolerance { get { return 1e-5; } }
+ protected virtual double MolesTolerance { get { return 1e-5; } }
+ protected virtual double NanomolesTolerance { get { return 1e-5; } }
+// ReSharper restore VirtualMemberNeverOverriden.Global
+
+ [Fact]
+ public void MoleToSubstanceAmountUnits()
+ {
+ SubstanceAmount mole = SubstanceAmount.FromMoles(1);
+ AssertEx.EqualTolerance(CentimolesInOneMole, mole.Centimoles, CentimolesTolerance);
+ AssertEx.EqualTolerance(DecimolesInOneMole, mole.Decimoles, DecimolesTolerance);
+ AssertEx.EqualTolerance(KilomolesInOneMole, mole.Kilomoles, KilomolesTolerance);
+ AssertEx.EqualTolerance(MicromolesInOneMole, mole.Micromoles, MicromolesTolerance);
+ AssertEx.EqualTolerance(MillimolesInOneMole, mole.Millimoles, MillimolesTolerance);
+ AssertEx.EqualTolerance(MolesInOneMole, mole.Moles, MolesTolerance);
+ AssertEx.EqualTolerance(NanomolesInOneMole, mole.Nanomoles, NanomolesTolerance);
+ }
+
+ [Fact]
+ public void FromValueAndUnit()
+ {
+ AssertEx.EqualTolerance(1, SubstanceAmount.From(1, SubstanceAmountUnit.Centimole).Centimoles, CentimolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.From(1, SubstanceAmountUnit.Decimole).Decimoles, DecimolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.From(1, SubstanceAmountUnit.Kilomole).Kilomoles, KilomolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.From(1, SubstanceAmountUnit.Micromole).Micromoles, MicromolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.From(1, SubstanceAmountUnit.Millimole).Millimoles, MillimolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.From(1, SubstanceAmountUnit.Mole).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.From(1, SubstanceAmountUnit.Nanomole).Nanomoles, NanomolesTolerance);
+ }
+
+ [Fact]
+ public void As()
+ {
+ var mole = SubstanceAmount.FromMoles(1);
+ AssertEx.EqualTolerance(CentimolesInOneMole, mole.As(SubstanceAmountUnit.Centimole), CentimolesTolerance);
+ AssertEx.EqualTolerance(DecimolesInOneMole, mole.As(SubstanceAmountUnit.Decimole), DecimolesTolerance);
+ AssertEx.EqualTolerance(KilomolesInOneMole, mole.As(SubstanceAmountUnit.Kilomole), KilomolesTolerance);
+ AssertEx.EqualTolerance(MicromolesInOneMole, mole.As(SubstanceAmountUnit.Micromole), MicromolesTolerance);
+ AssertEx.EqualTolerance(MillimolesInOneMole, mole.As(SubstanceAmountUnit.Millimole), MillimolesTolerance);
+ AssertEx.EqualTolerance(MolesInOneMole, mole.As(SubstanceAmountUnit.Mole), MolesTolerance);
+ AssertEx.EqualTolerance(NanomolesInOneMole, mole.As(SubstanceAmountUnit.Nanomole), NanomolesTolerance);
+ }
+
+ [Fact]
+ public void ConversionRoundTrip()
+ {
+ SubstanceAmount mole = SubstanceAmount.FromMoles(1);
+ AssertEx.EqualTolerance(1, SubstanceAmount.FromCentimoles(mole.Centimoles).Moles, CentimolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.FromDecimoles(mole.Decimoles).Moles, DecimolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.FromKilomoles(mole.Kilomoles).Moles, KilomolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.FromMicromoles(mole.Micromoles).Moles, MicromolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.FromMillimoles(mole.Millimoles).Moles, MillimolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.FromMoles(mole.Moles).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(1, SubstanceAmount.FromNanomoles(mole.Nanomoles).Moles, NanomolesTolerance);
+ }
+
+ [Fact]
+ public void ArithmeticOperators()
+ {
+ SubstanceAmount v = SubstanceAmount.FromMoles(1);
+ AssertEx.EqualTolerance(-1, -v.Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, (SubstanceAmount.FromMoles(3)-v).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, (v + v).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(10, (v*10).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(10, (10*v).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, (SubstanceAmount.FromMoles(10)/5).Moles, MolesTolerance);
+ AssertEx.EqualTolerance(2, SubstanceAmount.FromMoles(10)/SubstanceAmount.FromMoles(5), MolesTolerance);
+ }
+
+ [Fact]
+ public void ComparisonOperators()
+ {
+ SubstanceAmount oneMole = SubstanceAmount.FromMoles(1);
+ SubstanceAmount twoMoles = SubstanceAmount.FromMoles(2);
+
+ Assert.True(oneMole < twoMoles);
+ Assert.True(oneMole <= twoMoles);
+ Assert.True(twoMoles > oneMole);
+ Assert.True(twoMoles >= oneMole);
+
+ Assert.False(oneMole > twoMoles);
+ Assert.False(oneMole >= twoMoles);
+ Assert.False(twoMoles < oneMole);
+ Assert.False(twoMoles <= oneMole);
+ }
+
+ [Fact]
+ public void CompareToIsImplemented()
+ {
+ SubstanceAmount mole = SubstanceAmount.FromMoles(1);
+ Assert.Equal(0, mole.CompareTo(mole));
+ Assert.True(mole.CompareTo(SubstanceAmount.Zero) > 0);
+ Assert.True(SubstanceAmount.Zero.CompareTo(mole) < 0);
+ }
+
+ [Fact]
+ public void CompareToThrowsOnTypeMismatch()
+ {
+ SubstanceAmount mole = SubstanceAmount.FromMoles(1);
+ Assert.Throws(() => mole.CompareTo(new object()));
+ }
+
+ [Fact]
+ public void CompareToThrowsOnNull()
+ {
+ SubstanceAmount mole = SubstanceAmount.FromMoles(1);
+ Assert.Throws(() => mole.CompareTo(null));
+ }
+
+
+ [Fact]
+ public void EqualityOperators()
+ {
+ SubstanceAmount a = SubstanceAmount.FromMoles(1);
+ SubstanceAmount b = SubstanceAmount.FromMoles(2);
+
+// ReSharper disable EqualExpressionComparison
+ Assert.True(a == a);
+ Assert.True(a != b);
+
+ Assert.False(a == b);
+ Assert.False(a != a);
+// ReSharper restore EqualExpressionComparison
+ }
+
+ [Fact]
+ public void EqualsIsImplemented()
+ {
+ SubstanceAmount v = SubstanceAmount.FromMoles(1);
+ Assert.True(v.Equals(SubstanceAmount.FromMoles(1)));
+ Assert.False(v.Equals(SubstanceAmount.Zero));
+ }
+
+ [Fact]
+ public void EqualsReturnsFalseOnTypeMismatch()
+ {
+ SubstanceAmount mole = SubstanceAmount.FromMoles(1);
+ Assert.False(mole.Equals(new object()));
+ }
+
+ [Fact]
+ public void EqualsReturnsFalseOnNull()
+ {
+ SubstanceAmount mole = SubstanceAmount.FromMoles(1);
+ Assert.False(mole.Equals(null));
+ }
+ }
+}
diff --git a/UnitsNet/GeneratedCode/Enums/SubstanceAmountUnit.g.cs b/UnitsNet/GeneratedCode/Enums/SubstanceAmountUnit.g.cs
new file mode 100644
index 0000000000..5758da8bd8
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Enums/SubstanceAmountUnit.g.cs
@@ -0,0 +1,53 @@
+//------------------------------------------------------------------------------
+//
+// 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/anjdreas/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\UnitClasses\MyUnit.extra.cs files to add code to generated unit classes.
+// Add Extensions\MyUnitExtensions.cs to decorate unit classes with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or unit classes.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (anjdreas@gmail.com).
+// https://github.com/anjdreas/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+// ReSharper disable once CheckNamespace
+namespace UnitsNet.Units
+{
+ public enum SubstanceAmountUnit
+ {
+ Undefined = 0,
+ Centimole,
+ Decimole,
+ Kilomole,
+ Micromole,
+ Millimole,
+ Mole,
+ Nanomole,
+ }
+}
diff --git a/UnitsNet/GeneratedCode/Extensions/Number/NumberToAmountOfSubstanceExtensions.g.cs b/UnitsNet/GeneratedCode/Extensions/Number/NumberToAmountOfSubstanceExtensions.g.cs
new file mode 100644
index 0000000000..2d5e8e74f1
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Extensions/Number/NumberToAmountOfSubstanceExtensions.g.cs
@@ -0,0 +1,525 @@
+//------------------------------------------------------------------------------
+//
+// 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\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (angularsen@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+// Windows Runtime Component does not support extension methods and method overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+namespace UnitsNet.Extensions.NumberToAmountOfSubstance
+{
+ public static class NumberToAmountOfSubstanceExtensions
+ {
+ #region Centimole
+
+ ///
+ public static AmountOfSubstance Centimoles(this int value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance? Centimoles(this int? value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance Centimoles(this long value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance? Centimoles(this long? value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance Centimoles(this double value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance? Centimoles(this double? value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance Centimoles(this float value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance? Centimoles(this float? value) => AmountOfSubstance.FromCentimoles(value);
+
+ ///
+ public static AmountOfSubstance Centimoles(this decimal value) => AmountOfSubstance.FromCentimoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? Centimoles(this decimal? value) => AmountOfSubstance.FromCentimoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region CentipoundMole
+
+ ///
+ public static AmountOfSubstance CentipoundMoles(this int value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? CentipoundMoles(this int? value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance CentipoundMoles(this long value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? CentipoundMoles(this long? value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance CentipoundMoles(this double value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? CentipoundMoles(this double? value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance CentipoundMoles(this float value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? CentipoundMoles(this float? value) => AmountOfSubstance.FromCentipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance CentipoundMoles(this decimal value) => AmountOfSubstance.FromCentipoundMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? CentipoundMoles(this decimal? value) => AmountOfSubstance.FromCentipoundMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Decimole
+
+ ///
+ public static AmountOfSubstance Decimoles(this int value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance? Decimoles(this int? value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance Decimoles(this long value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance? Decimoles(this long? value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance Decimoles(this double value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance? Decimoles(this double? value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance Decimoles(this float value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance? Decimoles(this float? value) => AmountOfSubstance.FromDecimoles(value);
+
+ ///
+ public static AmountOfSubstance Decimoles(this decimal value) => AmountOfSubstance.FromDecimoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? Decimoles(this decimal? value) => AmountOfSubstance.FromDecimoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region DecipoundMole
+
+ ///
+ public static AmountOfSubstance DecipoundMoles(this int value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? DecipoundMoles(this int? value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance DecipoundMoles(this long value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? DecipoundMoles(this long? value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance DecipoundMoles(this double value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? DecipoundMoles(this double? value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance DecipoundMoles(this float value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? DecipoundMoles(this float? value) => AmountOfSubstance.FromDecipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance DecipoundMoles(this decimal value) => AmountOfSubstance.FromDecipoundMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? DecipoundMoles(this decimal? value) => AmountOfSubstance.FromDecipoundMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Kilomole
+
+ ///
+ public static AmountOfSubstance Kilomoles(this int value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance? Kilomoles(this int? value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance Kilomoles(this long value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance? Kilomoles(this long? value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance Kilomoles(this double value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance? Kilomoles(this double? value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance Kilomoles(this float value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance? Kilomoles(this float? value) => AmountOfSubstance.FromKilomoles(value);
+
+ ///
+ public static AmountOfSubstance Kilomoles(this decimal value) => AmountOfSubstance.FromKilomoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? Kilomoles(this decimal? value) => AmountOfSubstance.FromKilomoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region KilopoundMole
+
+ ///
+ public static AmountOfSubstance KilopoundMoles(this int value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? KilopoundMoles(this int? value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance KilopoundMoles(this long value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? KilopoundMoles(this long? value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance KilopoundMoles(this double value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? KilopoundMoles(this double? value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance KilopoundMoles(this float value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? KilopoundMoles(this float? value) => AmountOfSubstance.FromKilopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance KilopoundMoles(this decimal value) => AmountOfSubstance.FromKilopoundMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? KilopoundMoles(this decimal? value) => AmountOfSubstance.FromKilopoundMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Micromole
+
+ ///
+ public static AmountOfSubstance Micromoles(this int value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance? Micromoles(this int? value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance Micromoles(this long value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance? Micromoles(this long? value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance Micromoles(this double value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance? Micromoles(this double? value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance Micromoles(this float value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance? Micromoles(this float? value) => AmountOfSubstance.FromMicromoles(value);
+
+ ///
+ public static AmountOfSubstance Micromoles(this decimal value) => AmountOfSubstance.FromMicromoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? Micromoles(this decimal? value) => AmountOfSubstance.FromMicromoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region MicropoundMole
+
+ ///
+ public static AmountOfSubstance MicropoundMoles(this int value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MicropoundMoles(this int? value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MicropoundMoles(this long value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MicropoundMoles(this long? value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MicropoundMoles(this double value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MicropoundMoles(this double? value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MicropoundMoles(this float value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MicropoundMoles(this float? value) => AmountOfSubstance.FromMicropoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MicropoundMoles(this decimal value) => AmountOfSubstance.FromMicropoundMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? MicropoundMoles(this decimal? value) => AmountOfSubstance.FromMicropoundMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Millimole
+
+ ///
+ public static AmountOfSubstance Millimoles(this int value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance? Millimoles(this int? value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance Millimoles(this long value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance? Millimoles(this long? value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance Millimoles(this double value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance? Millimoles(this double? value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance Millimoles(this float value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance? Millimoles(this float? value) => AmountOfSubstance.FromMillimoles(value);
+
+ ///
+ public static AmountOfSubstance Millimoles(this decimal value) => AmountOfSubstance.FromMillimoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? Millimoles(this decimal? value) => AmountOfSubstance.FromMillimoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region MillipoundMole
+
+ ///
+ public static AmountOfSubstance MillipoundMoles(this int value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MillipoundMoles(this int? value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MillipoundMoles(this long value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MillipoundMoles(this long? value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MillipoundMoles(this double value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MillipoundMoles(this double? value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MillipoundMoles(this float value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? MillipoundMoles(this float? value) => AmountOfSubstance.FromMillipoundMoles(value);
+
+ ///
+ public static AmountOfSubstance MillipoundMoles(this decimal value) => AmountOfSubstance.FromMillipoundMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? MillipoundMoles(this decimal? value) => AmountOfSubstance.FromMillipoundMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Mole
+
+ ///
+ public static AmountOfSubstance Moles(this int value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance? Moles(this int? value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance Moles(this long value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance? Moles(this long? value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance Moles(this double value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance? Moles(this double? value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance Moles(this float value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance? Moles(this float? value) => AmountOfSubstance.FromMoles(value);
+
+ ///
+ public static AmountOfSubstance Moles(this decimal value) => AmountOfSubstance.FromMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? Moles(this decimal? value) => AmountOfSubstance.FromMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Nanomole
+
+ ///
+ public static AmountOfSubstance Nanomoles(this int value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance? Nanomoles(this int? value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance Nanomoles(this long value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance? Nanomoles(this long? value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance Nanomoles(this double value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance? Nanomoles(this double? value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance Nanomoles(this float value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance? Nanomoles(this float? value) => AmountOfSubstance.FromNanomoles(value);
+
+ ///
+ public static AmountOfSubstance Nanomoles(this decimal value) => AmountOfSubstance.FromNanomoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? Nanomoles(this decimal? value) => AmountOfSubstance.FromNanomoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region NanopoundMole
+
+ ///
+ public static AmountOfSubstance NanopoundMoles(this int value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? NanopoundMoles(this int? value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance NanopoundMoles(this long value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? NanopoundMoles(this long? value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance NanopoundMoles(this double value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? NanopoundMoles(this double? value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance NanopoundMoles(this float value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? NanopoundMoles(this float? value) => AmountOfSubstance.FromNanopoundMoles(value);
+
+ ///
+ public static AmountOfSubstance NanopoundMoles(this decimal value) => AmountOfSubstance.FromNanopoundMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? NanopoundMoles(this decimal? value) => AmountOfSubstance.FromNanopoundMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region PoundMole
+
+ ///
+ public static AmountOfSubstance PoundMoles(this int value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? PoundMoles(this int? value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance PoundMoles(this long value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? PoundMoles(this long? value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance PoundMoles(this double value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? PoundMoles(this double? value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance PoundMoles(this float value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance? PoundMoles(this float? value) => AmountOfSubstance.FromPoundMoles(value);
+
+ ///
+ public static AmountOfSubstance PoundMoles(this decimal value) => AmountOfSubstance.FromPoundMoles(Convert.ToDouble(value));
+
+ ///
+ public static AmountOfSubstance? PoundMoles(this decimal? value) => AmountOfSubstance.FromPoundMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ }
+}
+#endif
diff --git a/UnitsNet/GeneratedCode/Extensions/Number/NumberToSubstanceAmountExtensions.g.cs b/UnitsNet/GeneratedCode/Extensions/Number/NumberToSubstanceAmountExtensions.g.cs
new file mode 100644
index 0000000000..f80bbc5d7d
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Extensions/Number/NumberToSubstanceAmountExtensions.g.cs
@@ -0,0 +1,287 @@
+//------------------------------------------------------------------------------
+//
+// 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/anjdreas/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\UnitClasses\MyUnit.extra.cs files to add code to generated unit classes.
+// Add Extensions\MyUnitExtensions.cs to decorate unit classes with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or unit classes.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (anjdreas@gmail.com).
+// https://github.com/anjdreas/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+// Windows Runtime Component does not support extension methods and method overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+namespace UnitsNet.Extensions.NumberToSubstanceAmount
+{
+ public static class NumberToSubstanceAmountExtensions
+ {
+ #region Centimole
+
+ ///
+ public static SubstanceAmount Centimoles(this int value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount? Centimoles(this int? value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount Centimoles(this long value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount? Centimoles(this long? value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount Centimoles(this double value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount? Centimoles(this double? value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount Centimoles(this float value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount? Centimoles(this float? value) => SubstanceAmount.FromCentimoles(value);
+
+ ///
+ public static SubstanceAmount Centimoles(this decimal value) => SubstanceAmount.FromCentimoles(Convert.ToDouble(value));
+
+ ///
+ public static SubstanceAmount? Centimoles(this decimal? value) => SubstanceAmount.FromCentimoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Decimole
+
+ ///
+ public static SubstanceAmount Decimoles(this int value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount? Decimoles(this int? value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount Decimoles(this long value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount? Decimoles(this long? value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount Decimoles(this double value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount? Decimoles(this double? value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount Decimoles(this float value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount? Decimoles(this float? value) => SubstanceAmount.FromDecimoles(value);
+
+ ///
+ public static SubstanceAmount Decimoles(this decimal value) => SubstanceAmount.FromDecimoles(Convert.ToDouble(value));
+
+ ///
+ public static SubstanceAmount? Decimoles(this decimal? value) => SubstanceAmount.FromDecimoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Kilomole
+
+ ///
+ public static SubstanceAmount Kilomoles(this int value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount? Kilomoles(this int? value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount Kilomoles(this long value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount? Kilomoles(this long? value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount Kilomoles(this double value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount? Kilomoles(this double? value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount Kilomoles(this float value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount? Kilomoles(this float? value) => SubstanceAmount.FromKilomoles(value);
+
+ ///
+ public static SubstanceAmount Kilomoles(this decimal value) => SubstanceAmount.FromKilomoles(Convert.ToDouble(value));
+
+ ///
+ public static SubstanceAmount? Kilomoles(this decimal? value) => SubstanceAmount.FromKilomoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Micromole
+
+ ///
+ public static SubstanceAmount Micromoles(this int value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount? Micromoles(this int? value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount Micromoles(this long value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount? Micromoles(this long? value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount Micromoles(this double value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount? Micromoles(this double? value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount Micromoles(this float value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount? Micromoles(this float? value) => SubstanceAmount.FromMicromoles(value);
+
+ ///
+ public static SubstanceAmount Micromoles(this decimal value) => SubstanceAmount.FromMicromoles(Convert.ToDouble(value));
+
+ ///
+ public static SubstanceAmount? Micromoles(this decimal? value) => SubstanceAmount.FromMicromoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Millimole
+
+ ///
+ public static SubstanceAmount Millimoles(this int value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount? Millimoles(this int? value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount Millimoles(this long value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount? Millimoles(this long? value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount Millimoles(this double value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount? Millimoles(this double? value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount Millimoles(this float value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount? Millimoles(this float? value) => SubstanceAmount.FromMillimoles(value);
+
+ ///
+ public static SubstanceAmount Millimoles(this decimal value) => SubstanceAmount.FromMillimoles(Convert.ToDouble(value));
+
+ ///
+ public static SubstanceAmount? Millimoles(this decimal? value) => SubstanceAmount.FromMillimoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Mole
+
+ ///
+ public static SubstanceAmount Moles(this int value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount? Moles(this int? value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount Moles(this long value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount? Moles(this long? value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount Moles(this double value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount? Moles(this double? value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount Moles(this float value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount? Moles(this float? value) => SubstanceAmount.FromMoles(value);
+
+ ///
+ public static SubstanceAmount Moles(this decimal value) => SubstanceAmount.FromMoles(Convert.ToDouble(value));
+
+ ///
+ public static SubstanceAmount? Moles(this decimal? value) => SubstanceAmount.FromMoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region Nanomole
+
+ ///
+ public static SubstanceAmount Nanomoles(this int value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount? Nanomoles(this int? value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount Nanomoles(this long value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount? Nanomoles(this long? value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount Nanomoles(this double value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount? Nanomoles(this double? value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount Nanomoles(this float value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount? Nanomoles(this float? value) => SubstanceAmount.FromNanomoles(value);
+
+ ///
+ public static SubstanceAmount Nanomoles(this decimal value) => SubstanceAmount.FromNanomoles(Convert.ToDouble(value));
+
+ ///
+ public static SubstanceAmount? Nanomoles(this decimal? value) => SubstanceAmount.FromNanomoles(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ }
+}
+#endif
diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
new file mode 100644
index 0000000000..9cdfd0b9cb
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
@@ -0,0 +1,2176 @@
+//------------------------------------------------------------------------------
+//
+// 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\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (angularsen@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Text.RegularExpressions;
+using System.Linq;
+using JetBrains.Annotations;
+using UnitsNet.Units;
+
+// Windows Runtime Component does not support CultureInfo type, so use culture name string instead for public methods: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+using Culture = System.String;
+#else
+using Culture = System.IFormatProvider;
+#endif
+
+// 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.
+ ///
+ // ReSharper disable once PartialTypeWithSinglePart
+
+ // 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.
+#if WINDOWS_UWP
+ public sealed partial class AmountOfSubstance
+#else
+ public partial struct AmountOfSubstance : IComparable, IComparable
+#endif
+ {
+ ///
+ /// Base unit of AmountOfSubstance.
+ ///
+ private readonly double _moles;
+
+ // Windows Runtime Component requires a default constructor
+#if WINDOWS_UWP
+ public AmountOfSubstance() : this(0)
+ {
+ }
+#endif
+
+ public AmountOfSubstance(double moles)
+ {
+ _moles = Convert.ToDouble(moles);
+ }
+
+ // 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
+#if WINDOWS_UWP
+ private
+#else
+ public
+#endif
+ AmountOfSubstance(long moles)
+ {
+ _moles = Convert.ToDouble(moles);
+ }
+
+ // 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
+ // Windows Runtime Component does not support decimal type
+#if WINDOWS_UWP
+ private
+#else
+ public
+#endif
+ AmountOfSubstance(decimal moles)
+ {
+ _moles = Convert.ToDouble(moles);
+ }
+
+ #region Properties
+
+ ///
+ /// The of this quantity.
+ ///
+ public static QuantityType QuantityType => QuantityType.AmountOfSubstance;
+
+ ///
+ /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
+ ///
+ public static AmountOfSubstanceUnit BaseUnit
+ {
+ get { return AmountOfSubstanceUnit.Mole; }
+ }
+
+ ///
+ /// All units of measurement for the AmountOfSubstance quantity.
+ ///
+ public static AmountOfSubstanceUnit[] Units { get; } = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().ToArray();
+
+ ///
+ /// Get AmountOfSubstance in Centimoles.
+ ///
+ public double Centimoles
+ {
+ get { return (_moles) / 1e-2d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in CentipoundMoles.
+ ///
+ public double CentipoundMoles
+ {
+ get { return (_moles/453.59237) / 1e-2d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in Decimoles.
+ ///
+ public double Decimoles
+ {
+ get { return (_moles) / 1e-1d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in DecipoundMoles.
+ ///
+ public double DecipoundMoles
+ {
+ get { return (_moles/453.59237) / 1e-1d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in Kilomoles.
+ ///
+ public double Kilomoles
+ {
+ get { return (_moles) / 1e3d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in KilopoundMoles.
+ ///
+ public double KilopoundMoles
+ {
+ get { return (_moles/453.59237) / 1e3d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in Micromoles.
+ ///
+ public double Micromoles
+ {
+ get { return (_moles) / 1e-6d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in MicropoundMoles.
+ ///
+ public double MicropoundMoles
+ {
+ get { return (_moles/453.59237) / 1e-6d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in Millimoles.
+ ///
+ public double Millimoles
+ {
+ get { return (_moles) / 1e-3d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in MillipoundMoles.
+ ///
+ public double MillipoundMoles
+ {
+ get { return (_moles/453.59237) / 1e-3d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in Moles.
+ ///
+ public double Moles
+ {
+ get { return _moles; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in Nanomoles.
+ ///
+ public double Nanomoles
+ {
+ get { return (_moles) / 1e-9d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in NanopoundMoles.
+ ///
+ public double NanopoundMoles
+ {
+ get { return (_moles/453.59237) / 1e-9d; }
+ }
+
+ ///
+ /// Get AmountOfSubstance in PoundMoles.
+ ///
+ public double PoundMoles
+ {
+ get { return _moles/453.59237; }
+ }
+
+ #endregion
+
+ #region Static
+
+ public static AmountOfSubstance Zero
+ {
+ get { return new AmountOfSubstance(); }
+ }
+
+ ///
+ /// Get AmountOfSubstance from Centimoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromCentimoles(double centimoles)
+ {
+ return new AmountOfSubstance((centimoles) * 1e-2d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Centimoles.
+ ///
+ public static AmountOfSubstance FromCentimoles(int centimoles)
+ {
+ return new AmountOfSubstance((centimoles) * 1e-2d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Centimoles.
+ ///
+ public static AmountOfSubstance FromCentimoles(long centimoles)
+ {
+ return new AmountOfSubstance((centimoles) * 1e-2d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from Centimoles of type decimal.
+ ///
+ public static AmountOfSubstance FromCentimoles(decimal centimoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(centimoles)) * 1e-2d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from CentipoundMoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromCentipoundMoles(double centipoundmoles)
+ {
+ return new AmountOfSubstance((centipoundmoles*453.59237) * 1e-2d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from CentipoundMoles.
+ ///
+ public static AmountOfSubstance FromCentipoundMoles(int centipoundmoles)
+ {
+ return new AmountOfSubstance((centipoundmoles*453.59237) * 1e-2d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from CentipoundMoles.
+ ///
+ public static AmountOfSubstance FromCentipoundMoles(long centipoundmoles)
+ {
+ return new AmountOfSubstance((centipoundmoles*453.59237) * 1e-2d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from CentipoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance FromCentipoundMoles(decimal centipoundmoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(centipoundmoles)*453.59237) * 1e-2d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from Decimoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromDecimoles(double decimoles)
+ {
+ return new AmountOfSubstance((decimoles) * 1e-1d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Decimoles.
+ ///
+ public static AmountOfSubstance FromDecimoles(int decimoles)
+ {
+ return new AmountOfSubstance((decimoles) * 1e-1d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Decimoles.
+ ///
+ public static AmountOfSubstance FromDecimoles(long decimoles)
+ {
+ return new AmountOfSubstance((decimoles) * 1e-1d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from Decimoles of type decimal.
+ ///
+ public static AmountOfSubstance FromDecimoles(decimal decimoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(decimoles)) * 1e-1d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from DecipoundMoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromDecipoundMoles(double decipoundmoles)
+ {
+ return new AmountOfSubstance((decipoundmoles*453.59237) * 1e-1d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from DecipoundMoles.
+ ///
+ public static AmountOfSubstance FromDecipoundMoles(int decipoundmoles)
+ {
+ return new AmountOfSubstance((decipoundmoles*453.59237) * 1e-1d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from DecipoundMoles.
+ ///
+ public static AmountOfSubstance FromDecipoundMoles(long decipoundmoles)
+ {
+ return new AmountOfSubstance((decipoundmoles*453.59237) * 1e-1d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from DecipoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance FromDecipoundMoles(decimal decipoundmoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(decipoundmoles)*453.59237) * 1e-1d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from Kilomoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromKilomoles(double kilomoles)
+ {
+ return new AmountOfSubstance((kilomoles) * 1e3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Kilomoles.
+ ///
+ public static AmountOfSubstance FromKilomoles(int kilomoles)
+ {
+ return new AmountOfSubstance((kilomoles) * 1e3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Kilomoles.
+ ///
+ public static AmountOfSubstance FromKilomoles(long kilomoles)
+ {
+ return new AmountOfSubstance((kilomoles) * 1e3d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from Kilomoles of type decimal.
+ ///
+ public static AmountOfSubstance FromKilomoles(decimal kilomoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(kilomoles)) * 1e3d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from KilopoundMoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromKilopoundMoles(double kilopoundmoles)
+ {
+ return new AmountOfSubstance((kilopoundmoles*453.59237) * 1e3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from KilopoundMoles.
+ ///
+ public static AmountOfSubstance FromKilopoundMoles(int kilopoundmoles)
+ {
+ return new AmountOfSubstance((kilopoundmoles*453.59237) * 1e3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from KilopoundMoles.
+ ///
+ public static AmountOfSubstance FromKilopoundMoles(long kilopoundmoles)
+ {
+ return new AmountOfSubstance((kilopoundmoles*453.59237) * 1e3d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from KilopoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance FromKilopoundMoles(decimal kilopoundmoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(kilopoundmoles)*453.59237) * 1e3d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from Micromoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromMicromoles(double micromoles)
+ {
+ return new AmountOfSubstance((micromoles) * 1e-6d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Micromoles.
+ ///
+ public static AmountOfSubstance FromMicromoles(int micromoles)
+ {
+ return new AmountOfSubstance((micromoles) * 1e-6d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Micromoles.
+ ///
+ public static AmountOfSubstance FromMicromoles(long micromoles)
+ {
+ return new AmountOfSubstance((micromoles) * 1e-6d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from Micromoles of type decimal.
+ ///
+ public static AmountOfSubstance FromMicromoles(decimal micromoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(micromoles)) * 1e-6d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from MicropoundMoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromMicropoundMoles(double micropoundmoles)
+ {
+ return new AmountOfSubstance((micropoundmoles*453.59237) * 1e-6d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from MicropoundMoles.
+ ///
+ public static AmountOfSubstance FromMicropoundMoles(int micropoundmoles)
+ {
+ return new AmountOfSubstance((micropoundmoles*453.59237) * 1e-6d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from MicropoundMoles.
+ ///
+ public static AmountOfSubstance FromMicropoundMoles(long micropoundmoles)
+ {
+ return new AmountOfSubstance((micropoundmoles*453.59237) * 1e-6d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from MicropoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance FromMicropoundMoles(decimal micropoundmoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(micropoundmoles)*453.59237) * 1e-6d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from Millimoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromMillimoles(double millimoles)
+ {
+ return new AmountOfSubstance((millimoles) * 1e-3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Millimoles.
+ ///
+ public static AmountOfSubstance FromMillimoles(int millimoles)
+ {
+ return new AmountOfSubstance((millimoles) * 1e-3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Millimoles.
+ ///
+ public static AmountOfSubstance FromMillimoles(long millimoles)
+ {
+ return new AmountOfSubstance((millimoles) * 1e-3d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from Millimoles of type decimal.
+ ///
+ public static AmountOfSubstance FromMillimoles(decimal millimoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(millimoles)) * 1e-3d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from MillipoundMoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromMillipoundMoles(double millipoundmoles)
+ {
+ return new AmountOfSubstance((millipoundmoles*453.59237) * 1e-3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from MillipoundMoles.
+ ///
+ public static AmountOfSubstance FromMillipoundMoles(int millipoundmoles)
+ {
+ return new AmountOfSubstance((millipoundmoles*453.59237) * 1e-3d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from MillipoundMoles.
+ ///
+ public static AmountOfSubstance FromMillipoundMoles(long millipoundmoles)
+ {
+ return new AmountOfSubstance((millipoundmoles*453.59237) * 1e-3d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from MillipoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance FromMillipoundMoles(decimal millipoundmoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(millipoundmoles)*453.59237) * 1e-3d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from Moles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromMoles(double moles)
+ {
+ return new AmountOfSubstance(moles);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Moles.
+ ///
+ public static AmountOfSubstance FromMoles(int moles)
+ {
+ return new AmountOfSubstance(moles);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Moles.
+ ///
+ public static AmountOfSubstance FromMoles(long moles)
+ {
+ return new AmountOfSubstance(moles);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from Moles of type decimal.
+ ///
+ public static AmountOfSubstance FromMoles(decimal moles)
+ {
+ return new AmountOfSubstance(Convert.ToDouble(moles));
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from Nanomoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromNanomoles(double nanomoles)
+ {
+ return new AmountOfSubstance((nanomoles) * 1e-9d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Nanomoles.
+ ///
+ public static AmountOfSubstance FromNanomoles(int nanomoles)
+ {
+ return new AmountOfSubstance((nanomoles) * 1e-9d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from Nanomoles.
+ ///
+ public static AmountOfSubstance FromNanomoles(long nanomoles)
+ {
+ return new AmountOfSubstance((nanomoles) * 1e-9d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from Nanomoles of type decimal.
+ ///
+ public static AmountOfSubstance FromNanomoles(decimal nanomoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(nanomoles)) * 1e-9d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from NanopoundMoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromNanopoundMoles(double nanopoundmoles)
+ {
+ return new AmountOfSubstance((nanopoundmoles*453.59237) * 1e-9d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from NanopoundMoles.
+ ///
+ public static AmountOfSubstance FromNanopoundMoles(int nanopoundmoles)
+ {
+ return new AmountOfSubstance((nanopoundmoles*453.59237) * 1e-9d);
+ }
+
+ ///
+ /// Get AmountOfSubstance from NanopoundMoles.
+ ///
+ public static AmountOfSubstance FromNanopoundMoles(long nanopoundmoles)
+ {
+ return new AmountOfSubstance((nanopoundmoles*453.59237) * 1e-9d);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from NanopoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance FromNanopoundMoles(decimal nanopoundmoles)
+ {
+ return new AmountOfSubstance((Convert.ToDouble(nanopoundmoles)*453.59237) * 1e-9d);
+ }
+#endif
+
+ ///
+ /// Get AmountOfSubstance from PoundMoles.
+ ///
+#if NETFX_CORE
+ [Windows.Foundation.Metadata.DefaultOverload]
+#endif
+ public static AmountOfSubstance FromPoundMoles(double poundmoles)
+ {
+ return new AmountOfSubstance(poundmoles*453.59237);
+ }
+
+ ///
+ /// Get AmountOfSubstance from PoundMoles.
+ ///
+ public static AmountOfSubstance FromPoundMoles(int poundmoles)
+ {
+ return new AmountOfSubstance(poundmoles*453.59237);
+ }
+
+ ///
+ /// Get AmountOfSubstance from PoundMoles.
+ ///
+ public static AmountOfSubstance FromPoundMoles(long poundmoles)
+ {
+ return new AmountOfSubstance(poundmoles*453.59237);
+ }
+
+ // Windows Runtime Component does not support decimal type
+#if !WINDOWS_UWP
+ ///
+ /// Get AmountOfSubstance from PoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance FromPoundMoles(decimal poundmoles)
+ {
+ return new AmountOfSubstance(Convert.ToDouble(poundmoles)*453.59237);
+ }
+#endif
+
+ // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ ///
+ /// Get nullable AmountOfSubstance from nullable Centimoles.
+ ///
+ public static AmountOfSubstance? FromCentimoles(double? centimoles)
+ {
+ if (centimoles.HasValue)
+ {
+ return FromCentimoles(centimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Centimoles.
+ ///
+ public static AmountOfSubstance? FromCentimoles(int? centimoles)
+ {
+ if (centimoles.HasValue)
+ {
+ return FromCentimoles(centimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Centimoles.
+ ///
+ public static AmountOfSubstance? FromCentimoles(long? centimoles)
+ {
+ if (centimoles.HasValue)
+ {
+ return FromCentimoles(centimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from Centimoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromCentimoles(decimal? centimoles)
+ {
+ if (centimoles.HasValue)
+ {
+ return FromCentimoles(centimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable CentipoundMoles.
+ ///
+ public static AmountOfSubstance? FromCentipoundMoles(double? centipoundmoles)
+ {
+ if (centipoundmoles.HasValue)
+ {
+ return FromCentipoundMoles(centipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable CentipoundMoles.
+ ///
+ public static AmountOfSubstance? FromCentipoundMoles(int? centipoundmoles)
+ {
+ if (centipoundmoles.HasValue)
+ {
+ return FromCentipoundMoles(centipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable CentipoundMoles.
+ ///
+ public static AmountOfSubstance? FromCentipoundMoles(long? centipoundmoles)
+ {
+ if (centipoundmoles.HasValue)
+ {
+ return FromCentipoundMoles(centipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from CentipoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromCentipoundMoles(decimal? centipoundmoles)
+ {
+ if (centipoundmoles.HasValue)
+ {
+ return FromCentipoundMoles(centipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Decimoles.
+ ///
+ public static AmountOfSubstance? FromDecimoles(double? decimoles)
+ {
+ if (decimoles.HasValue)
+ {
+ return FromDecimoles(decimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Decimoles.
+ ///
+ public static AmountOfSubstance? FromDecimoles(int? decimoles)
+ {
+ if (decimoles.HasValue)
+ {
+ return FromDecimoles(decimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Decimoles.
+ ///
+ public static AmountOfSubstance? FromDecimoles(long? decimoles)
+ {
+ if (decimoles.HasValue)
+ {
+ return FromDecimoles(decimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from Decimoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromDecimoles(decimal? decimoles)
+ {
+ if (decimoles.HasValue)
+ {
+ return FromDecimoles(decimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable DecipoundMoles.
+ ///
+ public static AmountOfSubstance? FromDecipoundMoles(double? decipoundmoles)
+ {
+ if (decipoundmoles.HasValue)
+ {
+ return FromDecipoundMoles(decipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable DecipoundMoles.
+ ///
+ public static AmountOfSubstance? FromDecipoundMoles(int? decipoundmoles)
+ {
+ if (decipoundmoles.HasValue)
+ {
+ return FromDecipoundMoles(decipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable DecipoundMoles.
+ ///
+ public static AmountOfSubstance? FromDecipoundMoles(long? decipoundmoles)
+ {
+ if (decipoundmoles.HasValue)
+ {
+ return FromDecipoundMoles(decipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from DecipoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromDecipoundMoles(decimal? decipoundmoles)
+ {
+ if (decipoundmoles.HasValue)
+ {
+ return FromDecipoundMoles(decipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Kilomoles.
+ ///
+ public static AmountOfSubstance? FromKilomoles(double? kilomoles)
+ {
+ if (kilomoles.HasValue)
+ {
+ return FromKilomoles(kilomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Kilomoles.
+ ///
+ public static AmountOfSubstance? FromKilomoles(int? kilomoles)
+ {
+ if (kilomoles.HasValue)
+ {
+ return FromKilomoles(kilomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Kilomoles.
+ ///
+ public static AmountOfSubstance? FromKilomoles(long? kilomoles)
+ {
+ if (kilomoles.HasValue)
+ {
+ return FromKilomoles(kilomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from Kilomoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromKilomoles(decimal? kilomoles)
+ {
+ if (kilomoles.HasValue)
+ {
+ return FromKilomoles(kilomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable KilopoundMoles.
+ ///
+ public static AmountOfSubstance? FromKilopoundMoles(double? kilopoundmoles)
+ {
+ if (kilopoundmoles.HasValue)
+ {
+ return FromKilopoundMoles(kilopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable KilopoundMoles.
+ ///
+ public static AmountOfSubstance? FromKilopoundMoles(int? kilopoundmoles)
+ {
+ if (kilopoundmoles.HasValue)
+ {
+ return FromKilopoundMoles(kilopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable KilopoundMoles.
+ ///
+ public static AmountOfSubstance? FromKilopoundMoles(long? kilopoundmoles)
+ {
+ if (kilopoundmoles.HasValue)
+ {
+ return FromKilopoundMoles(kilopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from KilopoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromKilopoundMoles(decimal? kilopoundmoles)
+ {
+ if (kilopoundmoles.HasValue)
+ {
+ return FromKilopoundMoles(kilopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Micromoles.
+ ///
+ public static AmountOfSubstance? FromMicromoles(double? micromoles)
+ {
+ if (micromoles.HasValue)
+ {
+ return FromMicromoles(micromoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Micromoles.
+ ///
+ public static AmountOfSubstance? FromMicromoles(int? micromoles)
+ {
+ if (micromoles.HasValue)
+ {
+ return FromMicromoles(micromoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Micromoles.
+ ///
+ public static AmountOfSubstance? FromMicromoles(long? micromoles)
+ {
+ if (micromoles.HasValue)
+ {
+ return FromMicromoles(micromoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from Micromoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromMicromoles(decimal? micromoles)
+ {
+ if (micromoles.HasValue)
+ {
+ return FromMicromoles(micromoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable MicropoundMoles.
+ ///
+ public static AmountOfSubstance? FromMicropoundMoles(double? micropoundmoles)
+ {
+ if (micropoundmoles.HasValue)
+ {
+ return FromMicropoundMoles(micropoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable MicropoundMoles.
+ ///
+ public static AmountOfSubstance? FromMicropoundMoles(int? micropoundmoles)
+ {
+ if (micropoundmoles.HasValue)
+ {
+ return FromMicropoundMoles(micropoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable MicropoundMoles.
+ ///
+ public static AmountOfSubstance? FromMicropoundMoles(long? micropoundmoles)
+ {
+ if (micropoundmoles.HasValue)
+ {
+ return FromMicropoundMoles(micropoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from MicropoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromMicropoundMoles(decimal? micropoundmoles)
+ {
+ if (micropoundmoles.HasValue)
+ {
+ return FromMicropoundMoles(micropoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Millimoles.
+ ///
+ public static AmountOfSubstance? FromMillimoles(double? millimoles)
+ {
+ if (millimoles.HasValue)
+ {
+ return FromMillimoles(millimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Millimoles.
+ ///
+ public static AmountOfSubstance? FromMillimoles(int? millimoles)
+ {
+ if (millimoles.HasValue)
+ {
+ return FromMillimoles(millimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Millimoles.
+ ///
+ public static AmountOfSubstance? FromMillimoles(long? millimoles)
+ {
+ if (millimoles.HasValue)
+ {
+ return FromMillimoles(millimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from Millimoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromMillimoles(decimal? millimoles)
+ {
+ if (millimoles.HasValue)
+ {
+ return FromMillimoles(millimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable MillipoundMoles.
+ ///
+ public static AmountOfSubstance? FromMillipoundMoles(double? millipoundmoles)
+ {
+ if (millipoundmoles.HasValue)
+ {
+ return FromMillipoundMoles(millipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable MillipoundMoles.
+ ///
+ public static AmountOfSubstance? FromMillipoundMoles(int? millipoundmoles)
+ {
+ if (millipoundmoles.HasValue)
+ {
+ return FromMillipoundMoles(millipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable MillipoundMoles.
+ ///
+ public static AmountOfSubstance? FromMillipoundMoles(long? millipoundmoles)
+ {
+ if (millipoundmoles.HasValue)
+ {
+ return FromMillipoundMoles(millipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from MillipoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromMillipoundMoles(decimal? millipoundmoles)
+ {
+ if (millipoundmoles.HasValue)
+ {
+ return FromMillipoundMoles(millipoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Moles.
+ ///
+ public static AmountOfSubstance? FromMoles(double? moles)
+ {
+ if (moles.HasValue)
+ {
+ return FromMoles(moles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Moles.
+ ///
+ public static AmountOfSubstance? FromMoles(int? moles)
+ {
+ if (moles.HasValue)
+ {
+ return FromMoles(moles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Moles.
+ ///
+ public static AmountOfSubstance? FromMoles(long? moles)
+ {
+ if (moles.HasValue)
+ {
+ return FromMoles(moles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from Moles of type decimal.
+ ///
+ public static AmountOfSubstance? FromMoles(decimal? moles)
+ {
+ if (moles.HasValue)
+ {
+ return FromMoles(moles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Nanomoles.
+ ///
+ public static AmountOfSubstance? FromNanomoles(double? nanomoles)
+ {
+ if (nanomoles.HasValue)
+ {
+ return FromNanomoles(nanomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Nanomoles.
+ ///
+ public static AmountOfSubstance? FromNanomoles(int? nanomoles)
+ {
+ if (nanomoles.HasValue)
+ {
+ return FromNanomoles(nanomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable Nanomoles.
+ ///
+ public static AmountOfSubstance? FromNanomoles(long? nanomoles)
+ {
+ if (nanomoles.HasValue)
+ {
+ return FromNanomoles(nanomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from Nanomoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromNanomoles(decimal? nanomoles)
+ {
+ if (nanomoles.HasValue)
+ {
+ return FromNanomoles(nanomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable NanopoundMoles.
+ ///
+ public static AmountOfSubstance? FromNanopoundMoles(double? nanopoundmoles)
+ {
+ if (nanopoundmoles.HasValue)
+ {
+ return FromNanopoundMoles(nanopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable NanopoundMoles.
+ ///
+ public static AmountOfSubstance? FromNanopoundMoles(int? nanopoundmoles)
+ {
+ if (nanopoundmoles.HasValue)
+ {
+ return FromNanopoundMoles(nanopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable NanopoundMoles.
+ ///
+ public static AmountOfSubstance? FromNanopoundMoles(long? nanopoundmoles)
+ {
+ if (nanopoundmoles.HasValue)
+ {
+ return FromNanopoundMoles(nanopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from NanopoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromNanopoundMoles(decimal? nanopoundmoles)
+ {
+ if (nanopoundmoles.HasValue)
+ {
+ return FromNanopoundMoles(nanopoundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable PoundMoles.
+ ///
+ public static AmountOfSubstance? FromPoundMoles(double? poundmoles)
+ {
+ if (poundmoles.HasValue)
+ {
+ return FromPoundMoles(poundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable PoundMoles.
+ ///
+ public static AmountOfSubstance? FromPoundMoles(int? poundmoles)
+ {
+ if (poundmoles.HasValue)
+ {
+ return FromPoundMoles(poundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from nullable PoundMoles.
+ ///
+ public static AmountOfSubstance? FromPoundMoles(long? poundmoles)
+ {
+ if (poundmoles.HasValue)
+ {
+ return FromPoundMoles(poundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable AmountOfSubstance from PoundMoles of type decimal.
+ ///
+ public static AmountOfSubstance? FromPoundMoles(decimal? poundmoles)
+ {
+ if (poundmoles.HasValue)
+ {
+ return FromPoundMoles(poundmoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+#endif
+
+ ///
+ /// Dynamically convert from value and unit enum to .
+ ///
+ /// Value to convert from.
+ /// Unit to convert from.
+ /// AmountOfSubstance unit value.
+ public static AmountOfSubstance From(double val, AmountOfSubstanceUnit fromUnit)
+ {
+ switch (fromUnit)
+ {
+ case AmountOfSubstanceUnit.Centimole:
+ return FromCentimoles(val);
+ case AmountOfSubstanceUnit.CentipoundMole:
+ return FromCentipoundMoles(val);
+ case AmountOfSubstanceUnit.Decimole:
+ return FromDecimoles(val);
+ case AmountOfSubstanceUnit.DecipoundMole:
+ return FromDecipoundMoles(val);
+ case AmountOfSubstanceUnit.Kilomole:
+ return FromKilomoles(val);
+ case AmountOfSubstanceUnit.KilopoundMole:
+ return FromKilopoundMoles(val);
+ case AmountOfSubstanceUnit.Micromole:
+ return FromMicromoles(val);
+ case AmountOfSubstanceUnit.MicropoundMole:
+ return FromMicropoundMoles(val);
+ case AmountOfSubstanceUnit.Millimole:
+ return FromMillimoles(val);
+ case AmountOfSubstanceUnit.MillipoundMole:
+ return FromMillipoundMoles(val);
+ case AmountOfSubstanceUnit.Mole:
+ return FromMoles(val);
+ case AmountOfSubstanceUnit.Nanomole:
+ return FromNanomoles(val);
+ case AmountOfSubstanceUnit.NanopoundMole:
+ return FromNanopoundMoles(val);
+ case AmountOfSubstanceUnit.PoundMole:
+ return FromPoundMoles(val);
+
+ default:
+ throw new NotImplementedException("fromUnit: " + fromUnit);
+ }
+ }
+
+ // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ ///
+ /// Dynamically convert from value and unit enum to .
+ ///
+ /// Value to convert from.
+ /// Unit to convert from.
+ /// AmountOfSubstance unit value.
+ public static AmountOfSubstance? From(double? value, AmountOfSubstanceUnit fromUnit)
+ {
+ if (!value.HasValue)
+ {
+ return null;
+ }
+ switch (fromUnit)
+ {
+ case AmountOfSubstanceUnit.Centimole:
+ return FromCentimoles(value.Value);
+ case AmountOfSubstanceUnit.CentipoundMole:
+ return FromCentipoundMoles(value.Value);
+ case AmountOfSubstanceUnit.Decimole:
+ return FromDecimoles(value.Value);
+ case AmountOfSubstanceUnit.DecipoundMole:
+ return FromDecipoundMoles(value.Value);
+ case AmountOfSubstanceUnit.Kilomole:
+ return FromKilomoles(value.Value);
+ case AmountOfSubstanceUnit.KilopoundMole:
+ return FromKilopoundMoles(value.Value);
+ case AmountOfSubstanceUnit.Micromole:
+ return FromMicromoles(value.Value);
+ case AmountOfSubstanceUnit.MicropoundMole:
+ return FromMicropoundMoles(value.Value);
+ case AmountOfSubstanceUnit.Millimole:
+ return FromMillimoles(value.Value);
+ case AmountOfSubstanceUnit.MillipoundMole:
+ return FromMillipoundMoles(value.Value);
+ case AmountOfSubstanceUnit.Mole:
+ return FromMoles(value.Value);
+ case AmountOfSubstanceUnit.Nanomole:
+ return FromNanomoles(value.Value);
+ case AmountOfSubstanceUnit.NanopoundMole:
+ return FromNanopoundMoles(value.Value);
+ case AmountOfSubstanceUnit.PoundMole:
+ return FromPoundMoles(value.Value);
+
+ default:
+ throw new NotImplementedException("fromUnit: " + fromUnit);
+ }
+ }
+#endif
+
+ ///
+ /// Get unit abbreviation string.
+ ///
+ /// Unit to get abbreviation for.
+ /// Unit abbreviation string.
+ [UsedImplicitly]
+ public static string GetAbbreviation(AmountOfSubstanceUnit unit)
+ {
+ return GetAbbreviation(unit, null);
+ }
+
+ ///
+ /// Get unit abbreviation string.
+ ///
+ /// Unit to get abbreviation for.
+ /// Culture to use for localization. Defaults to Thread.CurrentUICulture.
+ /// Unit abbreviation string.
+ [UsedImplicitly]
+ public static string GetAbbreviation(AmountOfSubstanceUnit unit, [CanBeNull] Culture culture)
+ {
+ return UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit);
+ }
+
+ #endregion
+
+ #region Arithmetic Operators
+
+ // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ public static AmountOfSubstance operator -(AmountOfSubstance right)
+ {
+ return new AmountOfSubstance(-right._moles);
+ }
+
+ public static AmountOfSubstance operator +(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ return new AmountOfSubstance(left._moles + right._moles);
+ }
+
+ public static AmountOfSubstance operator -(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ return new AmountOfSubstance(left._moles - right._moles);
+ }
+
+ public static AmountOfSubstance operator *(double left, AmountOfSubstance right)
+ {
+ return new AmountOfSubstance(left*right._moles);
+ }
+
+ public static AmountOfSubstance operator *(AmountOfSubstance left, double right)
+ {
+ return new AmountOfSubstance(left._moles*(double)right);
+ }
+
+ public static AmountOfSubstance operator /(AmountOfSubstance left, double right)
+ {
+ return new AmountOfSubstance(left._moles/(double)right);
+ }
+
+ public static double operator /(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ return Convert.ToDouble(left._moles/right._moles);
+ }
+#endif
+
+ #endregion
+
+ #region Equality / IComparable
+
+ public int CompareTo(object obj)
+ {
+ if (obj == null) throw new ArgumentNullException("obj");
+ if (!(obj is AmountOfSubstance)) throw new ArgumentException("Expected type AmountOfSubstance.", "obj");
+ return CompareTo((AmountOfSubstance) obj);
+ }
+
+ // 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
+#if WINDOWS_UWP
+ internal
+#else
+ public
+#endif
+ int CompareTo(AmountOfSubstance other)
+ {
+ return _moles.CompareTo(other._moles);
+ }
+
+ // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ public static bool operator <=(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ return left._moles <= right._moles;
+ }
+
+ public static bool operator >=(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ return left._moles >= right._moles;
+ }
+
+ public static bool operator <(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ return left._moles < right._moles;
+ }
+
+ public static bool operator >(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ return left._moles > right._moles;
+ }
+
+ public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return left._moles == right._moles;
+ }
+
+ public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right)
+ {
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return left._moles != right._moles;
+ }
+#endif
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+
+ return _moles.Equals(((AmountOfSubstance) obj)._moles);
+ }
+
+ public override int GetHashCode()
+ {
+ return _moles.GetHashCode();
+ }
+
+ #endregion
+
+ #region Conversion
+
+ ///
+ /// Convert to the unit representation .
+ ///
+ /// Value in new unit if successful, exception otherwise.
+ /// If conversion was not successful.
+ public double As(AmountOfSubstanceUnit unit)
+ {
+ switch (unit)
+ {
+ case AmountOfSubstanceUnit.Centimole:
+ return Centimoles;
+ case AmountOfSubstanceUnit.CentipoundMole:
+ return CentipoundMoles;
+ case AmountOfSubstanceUnit.Decimole:
+ return Decimoles;
+ case AmountOfSubstanceUnit.DecipoundMole:
+ return DecipoundMoles;
+ case AmountOfSubstanceUnit.Kilomole:
+ return Kilomoles;
+ case AmountOfSubstanceUnit.KilopoundMole:
+ return KilopoundMoles;
+ case AmountOfSubstanceUnit.Micromole:
+ return Micromoles;
+ case AmountOfSubstanceUnit.MicropoundMole:
+ return MicropoundMoles;
+ case AmountOfSubstanceUnit.Millimole:
+ return Millimoles;
+ case AmountOfSubstanceUnit.MillipoundMole:
+ return MillipoundMoles;
+ case AmountOfSubstanceUnit.Mole:
+ return Moles;
+ case AmountOfSubstanceUnit.Nanomole:
+ return Nanomoles;
+ case AmountOfSubstanceUnit.NanopoundMole:
+ return NanopoundMoles;
+ case AmountOfSubstanceUnit.PoundMole:
+ return PoundMoles;
+
+ default:
+ throw new NotImplementedException("unit: " + unit);
+ }
+ }
+
+ #endregion
+
+ #region Parsing
+
+ ///
+ /// 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}
+ /// Format to use when parsing number and unit. If it is null, it defaults to for parsing the number and for parsing the unit abbreviation by culture/language.
+ ///
+ /// 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, [CanBeNull] Culture culture)
+ {
+ if (str == null) throw new ArgumentNullException("str");
+
+ // Windows Runtime Component does not support CultureInfo type, so use culture name string for public methods instead: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+ IFormatProvider formatProvider = culture == null ? null : new CultureInfo(culture);
+#else
+ IFormatProvider formatProvider = culture;
+#endif
+ return QuantityParser.Parse(str, formatProvider,
+ delegate(string value, string unit, IFormatProvider formatProvider2)
+ {
+ double parsedValue = double.Parse(value, formatProvider2);
+ AmountOfSubstanceUnit parsedUnit = ParseUnit(unit, formatProvider2);
+ return From(parsedValue, parsedUnit);
+ }, (x, y) => FromMoles(x.Moles + y.Moles));
+ }
+
+ ///
+ /// 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}
+ /// Format to use when parsing number and unit. If it is null, it defaults to for parsing the number and for parsing the unit abbreviation by culture/language.
+ /// Resulting unit quantity if successful.
+ ///
+ /// Length.Parse("5.5 m", new CultureInfo("en-US"));
+ ///
+ public static bool TryParse([CanBeNull] string str, [CanBeNull] Culture culture, out AmountOfSubstance result)
+ {
+ try
+ {
+ result = Parse(str, culture);
+ return true;
+ }
+ catch
+ {
+ result = default(AmountOfSubstance);
+ return false;
+ }
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// 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, (IFormatProvider)null);
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing string.
+ public static AmountOfSubstanceUnit ParseUnit(string str, [CanBeNull] string cultureName)
+ {
+ return ParseUnit(str, cultureName == null ? null : new CultureInfo(cultureName));
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing 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
+#if WINDOWS_UWP
+ internal
+#else
+ public
+#endif
+ static AmountOfSubstanceUnit ParseUnit(string str, IFormatProvider formatProvider = null)
+ {
+ if (str == null) throw new ArgumentNullException("str");
+
+ var unitSystem = UnitSystem.GetCached(formatProvider);
+ var unit = unitSystem.Parse(str.Trim());
+
+ if (unit == AmountOfSubstanceUnit.Undefined)
+ {
+ var newEx = new UnitsNetException("Error parsing string. The unit is not a recognized AmountOfSubstanceUnit.");
+ newEx.Data["input"] = str;
+ newEx.Data["formatprovider"] = formatProvider?.ToString() ?? "(null)";
+ throw newEx;
+ }
+
+ return unit;
+ }
+
+ #endregion
+
+ ///
+ /// Set the default unit used by ToString(). Default is Mole
+ ///
+ public static AmountOfSubstanceUnit ToStringDefaultUnit { get; set; } = AmountOfSubstanceUnit.Mole;
+
+ ///
+ /// Get default string representation of value and unit.
+ ///
+ /// String representation.
+ public override string ToString()
+ {
+ return ToString(ToStringDefaultUnit);
+ }
+
+ ///
+ /// Get string representation of value and unit. Using current UI culture and two significant digits after radix.
+ ///
+ /// Unit representation to use.
+ /// String representation.
+ public string ToString(AmountOfSubstanceUnit unit)
+ {
+ return ToString(unit, null, 2);
+ }
+
+ ///
+ /// Get string representation of value and unit. Using two significant digits after radix.
+ ///
+ /// Unit representation to use.
+ /// Culture to use for localization and number formatting.
+ /// String representation.
+ public string ToString(AmountOfSubstanceUnit unit, [CanBeNull] Culture culture)
+ {
+ return ToString(unit, culture, 2);
+ }
+
+ ///
+ /// Get string representation of value and unit.
+ ///
+ /// Unit representation to use.
+ /// Culture to use for localization and number formatting.
+ /// The number of significant digits after the radix point.
+ /// String representation.
+ [UsedImplicitly]
+ public string ToString(AmountOfSubstanceUnit unit, [CanBeNull] Culture culture, int significantDigitsAfterRadix)
+ {
+ double value = As(unit);
+ string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
+ return ToString(unit, culture, format);
+ }
+
+ ///
+ /// Get string representation of value and unit.
+ ///
+ /// Culture to use for localization and number formatting.
+ /// Unit representation to use.
+ /// 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.
+ [UsedImplicitly]
+ public string ToString(AmountOfSubstanceUnit unit, [CanBeNull] Culture culture, [NotNull] string format,
+ [NotNull] params object[] args)
+ {
+ if (format == null) throw new ArgumentNullException(nameof(format));
+ if (args == null) throw new ArgumentNullException(nameof(args));
+
+ // Windows Runtime Component does not support CultureInfo type, so use culture name string for public methods instead: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+ IFormatProvider formatProvider = culture == null ? null : new CultureInfo(culture);
+#else
+ IFormatProvider formatProvider = culture;
+#endif
+ double value = As(unit);
+ object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
+ return string.Format(formatProvider, format, formatArgs);
+ }
+
+ ///
+ /// Represents the largest possible value of AmountOfSubstance
+ ///
+ public static AmountOfSubstance MaxValue
+ {
+ get
+ {
+ return new AmountOfSubstance(double.MaxValue);
+ }
+ }
+
+ ///
+ /// Represents the smallest possible value of AmountOfSubstance
+ ///
+ public static AmountOfSubstance MinValue
+ {
+ get
+ {
+ return new AmountOfSubstance(double.MinValue);
+ }
+ }
+ }
+}
diff --git a/UnitsNet/GeneratedCode/QuantityType.g.cs b/UnitsNet/GeneratedCode/QuantityType.g.cs
index 753bf3bf6b..dedd3bcc79 100644
--- a/UnitsNet/GeneratedCode/QuantityType.g.cs
+++ b/UnitsNet/GeneratedCode/QuantityType.g.cs
@@ -50,6 +50,7 @@ public enum QuantityType
{
Undefined = 0,
Acceleration,
+ AmountOfSubstance,
AmplitudeRatio,
Angle,
ApparentPower,
diff --git a/UnitsNet/GeneratedCode/UnitClasses/SubstanceAmount.g.cs b/UnitsNet/GeneratedCode/UnitClasses/SubstanceAmount.g.cs
new file mode 100644
index 0000000000..1d869f226b
--- /dev/null
+++ b/UnitsNet/GeneratedCode/UnitClasses/SubstanceAmount.g.cs
@@ -0,0 +1,867 @@
+//------------------------------------------------------------------------------
+//
+// 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/anjdreas/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\UnitClasses\MyUnit.extra.cs files to add code to generated unit classes.
+// Add Extensions\MyUnitExtensions.cs to decorate unit classes with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or unit classes.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (anjdreas@gmail.com).
+// https://github.com/anjdreas/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Text.RegularExpressions;
+using System.Linq;
+using JetBrains.Annotations;
+using UnitsNet.Units;
+
+// Windows Runtime Component does not support CultureInfo type, so use culture name string instead for public methods: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+using Culture = System.String;
+#else
+using Culture = System.IFormatProvider;
+#endif
+
+// 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.
+ ///
+ // ReSharper disable once PartialTypeWithSinglePart
+
+ // 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.
+#if WINDOWS_UWP
+ public sealed partial class SubstanceAmount
+#else
+ public partial struct SubstanceAmount : IComparable, IComparable
+#endif
+ {
+ ///
+ /// Base unit of SubstanceAmount.
+ ///
+ private readonly double _moles;
+
+ // Windows Runtime Component requires a default constructor
+#if WINDOWS_UWP
+ public SubstanceAmount() : this(0)
+ {
+ }
+#endif
+
+ public SubstanceAmount(double moles)
+ {
+ _moles = Convert.ToDouble(moles);
+ }
+
+ // 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
+#if WINDOWS_UWP
+ private
+#else
+ public
+#endif
+ SubstanceAmount(long moles)
+ {
+ _moles = Convert.ToDouble(moles);
+ }
+
+ // 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
+ // Windows Runtime Component does not support decimal type
+#if WINDOWS_UWP
+ private
+#else
+ public
+#endif
+ SubstanceAmount(decimal moles)
+ {
+ _moles = Convert.ToDouble(moles);
+ }
+
+ #region Properties
+
+ ///
+ /// The of this quantity.
+ ///
+ public static QuantityType QuantityType => QuantityType.AmountOfSubstance;
+
+ ///
+ /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
+ ///
+ public static SubstanceAmountUnit BaseUnit
+ {
+ get { return SubstanceAmountUnit.Mole; }
+ }
+
+ ///
+ /// All units of measurement for the SubstanceAmount quantity.
+ ///
+ public static SubstanceAmountUnit[] Units { get; } = Enum.GetValues(typeof(SubstanceAmountUnit)).Cast().ToArray();
+
+ ///
+ /// Get SubstanceAmount in Centimoles.
+ ///
+ public double Centimoles
+ {
+ get { return (_moles) / 1e-2d; }
+ }
+
+ ///
+ /// Get SubstanceAmount in Decimoles.
+ ///
+ public double Decimoles
+ {
+ get { return (_moles) / 1e-1d; }
+ }
+
+ ///
+ /// Get SubstanceAmount in Kilomoles.
+ ///
+ public double Kilomoles
+ {
+ get { return (_moles) / 1e3d; }
+ }
+
+ ///
+ /// Get SubstanceAmount in Micromoles.
+ ///
+ public double Micromoles
+ {
+ get { return (_moles) / 1e-6d; }
+ }
+
+ ///
+ /// Get SubstanceAmount in Millimoles.
+ ///
+ public double Millimoles
+ {
+ get { return (_moles) / 1e-3d; }
+ }
+
+ ///
+ /// Get SubstanceAmount in Moles.
+ ///
+ public double Moles
+ {
+ get { return _moles; }
+ }
+
+ ///
+ /// Get SubstanceAmount in Nanomoles.
+ ///
+ public double Nanomoles
+ {
+ get { return (_moles) / 1e-9d; }
+ }
+
+ #endregion
+
+ #region Static
+
+ public static SubstanceAmount Zero
+ {
+ get { return new SubstanceAmount(); }
+ }
+
+ ///
+ /// Get SubstanceAmount from Centimoles.
+ ///
+ public static SubstanceAmount FromCentimoles(double centimoles)
+ {
+ return new SubstanceAmount((centimoles) * 1e-2d);
+ }
+
+ ///
+ /// Get SubstanceAmount from Decimoles.
+ ///
+ public static SubstanceAmount FromDecimoles(double decimoles)
+ {
+ return new SubstanceAmount((decimoles) * 1e-1d);
+ }
+
+ ///
+ /// Get SubstanceAmount from Kilomoles.
+ ///
+ public static SubstanceAmount FromKilomoles(double kilomoles)
+ {
+ return new SubstanceAmount((kilomoles) * 1e3d);
+ }
+
+ ///
+ /// Get SubstanceAmount from Micromoles.
+ ///
+ public static SubstanceAmount FromMicromoles(double micromoles)
+ {
+ return new SubstanceAmount((micromoles) * 1e-6d);
+ }
+
+ ///
+ /// Get SubstanceAmount from Millimoles.
+ ///
+ public static SubstanceAmount FromMillimoles(double millimoles)
+ {
+ return new SubstanceAmount((millimoles) * 1e-3d);
+ }
+
+ ///
+ /// Get SubstanceAmount from Moles.
+ ///
+ public static SubstanceAmount FromMoles(double moles)
+ {
+ return new SubstanceAmount(moles);
+ }
+
+ ///
+ /// Get SubstanceAmount from Nanomoles.
+ ///
+ public static SubstanceAmount FromNanomoles(double nanomoles)
+ {
+ return new SubstanceAmount((nanomoles) * 1e-9d);
+ }
+
+ // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ ///
+ /// Get nullable SubstanceAmount from nullable Centimoles.
+ ///
+ public static SubstanceAmount? FromCentimoles(double? centimoles)
+ {
+ if (centimoles.HasValue)
+ {
+ return FromCentimoles(centimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable SubstanceAmount from nullable Decimoles.
+ ///
+ public static SubstanceAmount? FromDecimoles(double? decimoles)
+ {
+ if (decimoles.HasValue)
+ {
+ return FromDecimoles(decimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable SubstanceAmount from nullable Kilomoles.
+ ///
+ public static SubstanceAmount? FromKilomoles(double? kilomoles)
+ {
+ if (kilomoles.HasValue)
+ {
+ return FromKilomoles(kilomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable SubstanceAmount from nullable Micromoles.
+ ///
+ public static SubstanceAmount? FromMicromoles(double? micromoles)
+ {
+ if (micromoles.HasValue)
+ {
+ return FromMicromoles(micromoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable SubstanceAmount from nullable Millimoles.
+ ///
+ public static SubstanceAmount? FromMillimoles(double? millimoles)
+ {
+ if (millimoles.HasValue)
+ {
+ return FromMillimoles(millimoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable SubstanceAmount from nullable Moles.
+ ///
+ public static SubstanceAmount? FromMoles(double? moles)
+ {
+ if (moles.HasValue)
+ {
+ return FromMoles(moles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable SubstanceAmount from nullable Nanomoles.
+ ///
+ public static SubstanceAmount? FromNanomoles(double? nanomoles)
+ {
+ if (nanomoles.HasValue)
+ {
+ return FromNanomoles(nanomoles.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+#endif
+
+ ///
+ /// Dynamically convert from value and unit enum to .
+ ///
+ /// Value to convert from.
+ /// Unit to convert from.
+ /// SubstanceAmount unit value.
+ public static SubstanceAmount From(double val, SubstanceAmountUnit fromUnit)
+ {
+ switch (fromUnit)
+ {
+ case SubstanceAmountUnit.Centimole:
+ return FromCentimoles(val);
+ case SubstanceAmountUnit.Decimole:
+ return FromDecimoles(val);
+ case SubstanceAmountUnit.Kilomole:
+ return FromKilomoles(val);
+ case SubstanceAmountUnit.Micromole:
+ return FromMicromoles(val);
+ case SubstanceAmountUnit.Millimole:
+ return FromMillimoles(val);
+ case SubstanceAmountUnit.Mole:
+ return FromMoles(val);
+ case SubstanceAmountUnit.Nanomole:
+ return FromNanomoles(val);
+
+ default:
+ throw new NotImplementedException("fromUnit: " + fromUnit);
+ }
+ }
+
+ // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ ///
+ /// Dynamically convert from value and unit enum to .
+ ///
+ /// Value to convert from.
+ /// Unit to convert from.
+ /// SubstanceAmount unit value.
+ public static SubstanceAmount? From(double? value, SubstanceAmountUnit fromUnit)
+ {
+ if (!value.HasValue)
+ {
+ return null;
+ }
+ switch (fromUnit)
+ {
+ case SubstanceAmountUnit.Centimole:
+ return FromCentimoles(value.Value);
+ case SubstanceAmountUnit.Decimole:
+ return FromDecimoles(value.Value);
+ case SubstanceAmountUnit.Kilomole:
+ return FromKilomoles(value.Value);
+ case SubstanceAmountUnit.Micromole:
+ return FromMicromoles(value.Value);
+ case SubstanceAmountUnit.Millimole:
+ return FromMillimoles(value.Value);
+ case SubstanceAmountUnit.Mole:
+ return FromMoles(value.Value);
+ case SubstanceAmountUnit.Nanomole:
+ return FromNanomoles(value.Value);
+
+ default:
+ throw new NotImplementedException("fromUnit: " + fromUnit);
+ }
+ }
+#endif
+
+ ///
+ /// Get unit abbreviation string.
+ ///
+ /// Unit to get abbreviation for.
+ /// Unit abbreviation string.
+ [UsedImplicitly]
+ public static string GetAbbreviation(SubstanceAmountUnit unit)
+ {
+ return GetAbbreviation(unit, null);
+ }
+
+ ///
+ /// Get unit abbreviation string.
+ ///
+ /// Unit to get abbreviation for.
+ /// Culture to use for localization. Defaults to Thread.CurrentUICulture.
+ /// Unit abbreviation string.
+ [UsedImplicitly]
+ public static string GetAbbreviation(SubstanceAmountUnit unit, [CanBeNull] Culture culture)
+ {
+ return UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit);
+ }
+
+ #endregion
+
+ #region Arithmetic Operators
+
+ // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ public static SubstanceAmount operator -(SubstanceAmount right)
+ {
+ return new SubstanceAmount(-right._moles);
+ }
+
+ public static SubstanceAmount operator +(SubstanceAmount left, SubstanceAmount right)
+ {
+ return new SubstanceAmount(left._moles + right._moles);
+ }
+
+ public static SubstanceAmount operator -(SubstanceAmount left, SubstanceAmount right)
+ {
+ return new SubstanceAmount(left._moles - right._moles);
+ }
+
+ public static SubstanceAmount operator *(double left, SubstanceAmount right)
+ {
+ return new SubstanceAmount(left*right._moles);
+ }
+
+ public static SubstanceAmount operator *(SubstanceAmount left, double right)
+ {
+ return new SubstanceAmount(left._moles*(double)right);
+ }
+
+ public static SubstanceAmount operator /(SubstanceAmount left, double right)
+ {
+ return new SubstanceAmount(left._moles/(double)right);
+ }
+
+ public static double operator /(SubstanceAmount left, SubstanceAmount right)
+ {
+ return Convert.ToDouble(left._moles/right._moles);
+ }
+#endif
+
+ #endregion
+
+ #region Equality / IComparable
+
+ public int CompareTo(object obj)
+ {
+ if (obj == null) throw new ArgumentNullException("obj");
+ if (!(obj is SubstanceAmount)) throw new ArgumentException("Expected type SubstanceAmount.", "obj");
+ return CompareTo((SubstanceAmount) obj);
+ }
+
+ // 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
+#if WINDOWS_UWP
+ internal
+#else
+ public
+#endif
+ int CompareTo(SubstanceAmount other)
+ {
+ return _moles.CompareTo(other._moles);
+ }
+
+ // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ public static bool operator <=(SubstanceAmount left, SubstanceAmount right)
+ {
+ return left._moles <= right._moles;
+ }
+
+ public static bool operator >=(SubstanceAmount left, SubstanceAmount right)
+ {
+ return left._moles >= right._moles;
+ }
+
+ public static bool operator <(SubstanceAmount left, SubstanceAmount right)
+ {
+ return left._moles < right._moles;
+ }
+
+ public static bool operator >(SubstanceAmount left, SubstanceAmount right)
+ {
+ return left._moles > right._moles;
+ }
+
+ public static bool operator ==(SubstanceAmount left, SubstanceAmount right)
+ {
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return left._moles == right._moles;
+ }
+
+ public static bool operator !=(SubstanceAmount left, SubstanceAmount right)
+ {
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return left._moles != right._moles;
+ }
+#endif
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+
+ return _moles.Equals(((SubstanceAmount) obj)._moles);
+ }
+
+ public override int GetHashCode()
+ {
+ return _moles.GetHashCode();
+ }
+
+ #endregion
+
+ #region Conversion
+
+ ///
+ /// Convert to the unit representation .
+ ///
+ /// Value in new unit if successful, exception otherwise.
+ /// If conversion was not successful.
+ public double As(SubstanceAmountUnit unit)
+ {
+ switch (unit)
+ {
+ case SubstanceAmountUnit.Centimole:
+ return Centimoles;
+ case SubstanceAmountUnit.Decimole:
+ return Decimoles;
+ case SubstanceAmountUnit.Kilomole:
+ return Kilomoles;
+ case SubstanceAmountUnit.Micromole:
+ return Micromoles;
+ case SubstanceAmountUnit.Millimole:
+ return Millimoles;
+ case SubstanceAmountUnit.Mole:
+ return Moles;
+ case SubstanceAmountUnit.Nanomole:
+ return Nanomoles;
+
+ default:
+ throw new NotImplementedException("unit: " + unit);
+ }
+ }
+
+ #endregion
+
+ #region Parsing
+
+ ///
+ /// 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 SubstanceAmount 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}
+ /// Format to use when parsing number and unit. If it is null, it defaults to for parsing the number and for parsing the unit abbreviation by culture/language.
+ ///
+ /// 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 SubstanceAmount Parse(string str, [CanBeNull] Culture culture)
+ {
+ if (str == null) throw new ArgumentNullException("str");
+
+ // Windows Runtime Component does not support CultureInfo type, so use culture name string for public methods instead: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+ IFormatProvider formatProvider = culture == null ? null : new CultureInfo(culture);
+#else
+ IFormatProvider formatProvider = culture;
+#endif
+ return QuantityParser.Parse(str, formatProvider,
+ delegate(string value, string unit, IFormatProvider formatProvider2)
+ {
+ double parsedValue = double.Parse(value, formatProvider2);
+ SubstanceAmountUnit parsedUnit = ParseUnit(unit, formatProvider2);
+ return From(parsedValue, parsedUnit);
+ }, (x, y) => FromMoles(x.Moles + y.Moles));
+ }
+
+ ///
+ /// 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 SubstanceAmount 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}
+ /// Format to use when parsing number and unit. If it is null, it defaults to for parsing the number and for parsing the unit abbreviation by culture/language.
+ /// Resulting unit quantity if successful.
+ ///
+ /// Length.Parse("5.5 m", new CultureInfo("en-US"));
+ ///
+ public static bool TryParse([CanBeNull] string str, [CanBeNull] Culture culture, out SubstanceAmount result)
+ {
+ try
+ {
+ result = Parse(str, culture);
+ return true;
+ }
+ catch
+ {
+ result = default(SubstanceAmount);
+ return false;
+ }
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing string.
+ public static SubstanceAmountUnit ParseUnit(string str)
+ {
+ return ParseUnit(str, (IFormatProvider)null);
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing string.
+ public static SubstanceAmountUnit ParseUnit(string str, [CanBeNull] string cultureName)
+ {
+ return ParseUnit(str, cultureName == null ? null : new CultureInfo(cultureName));
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing 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
+#if WINDOWS_UWP
+ internal
+#else
+ public
+#endif
+ static SubstanceAmountUnit ParseUnit(string str, IFormatProvider formatProvider = null)
+ {
+ if (str == null) throw new ArgumentNullException("str");
+
+ var unitSystem = UnitSystem.GetCached(formatProvider);
+ var unit = unitSystem.Parse(str.Trim());
+
+ if (unit == SubstanceAmountUnit.Undefined)
+ {
+ var newEx = new UnitsNetException("Error parsing string. The unit is not a recognized SubstanceAmountUnit.");
+ newEx.Data["input"] = str;
+ newEx.Data["formatprovider"] = formatProvider?.ToString() ?? "(null)";
+ throw newEx;
+ }
+
+ return unit;
+ }
+
+ #endregion
+
+ ///
+ /// Set the default unit used by ToString(). Default is Mole
+ ///
+ public static SubstanceAmountUnit ToStringDefaultUnit { get; set; } = SubstanceAmountUnit.Mole;
+
+ ///
+ /// Get default string representation of value and unit.
+ ///
+ /// String representation.
+ public override string ToString()
+ {
+ return ToString(ToStringDefaultUnit);
+ }
+
+ ///
+ /// Get string representation of value and unit. Using current UI culture and two significant digits after radix.
+ ///
+ /// Unit representation to use.
+ /// String representation.
+ public string ToString(SubstanceAmountUnit unit)
+ {
+ return ToString(unit, null, 2);
+ }
+
+ ///
+ /// Get string representation of value and unit. Using two significant digits after radix.
+ ///
+ /// Unit representation to use.
+ /// Culture to use for localization and number formatting.
+ /// String representation.
+ public string ToString(SubstanceAmountUnit unit, [CanBeNull] Culture culture)
+ {
+ return ToString(unit, culture, 2);
+ }
+
+ ///
+ /// Get string representation of value and unit.
+ ///
+ /// Unit representation to use.
+ /// Culture to use for localization and number formatting.
+ /// The number of significant digits after the radix point.
+ /// String representation.
+ [UsedImplicitly]
+ public string ToString(SubstanceAmountUnit unit, [CanBeNull] Culture culture, int significantDigitsAfterRadix)
+ {
+ double value = As(unit);
+ string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
+ return ToString(unit, culture, format);
+ }
+
+ ///
+ /// Get string representation of value and unit.
+ ///
+ /// Culture to use for localization and number formatting.
+ /// Unit representation to use.
+ /// 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.
+ [UsedImplicitly]
+ public string ToString(SubstanceAmountUnit unit, [CanBeNull] Culture culture, [NotNull] string format,
+ [NotNull] params object[] args)
+ {
+ if (format == null) throw new ArgumentNullException(nameof(format));
+ if (args == null) throw new ArgumentNullException(nameof(args));
+
+ // Windows Runtime Component does not support CultureInfo type, so use culture name string for public methods instead: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+ IFormatProvider formatProvider = culture == null ? null : new CultureInfo(culture);
+#else
+ IFormatProvider formatProvider = culture;
+#endif
+ double value = As(unit);
+ object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
+ return string.Format(formatProvider, format, formatArgs);
+ }
+
+ ///
+ /// Represents the largest possible value of SubstanceAmount
+ ///
+ public static SubstanceAmount MaxValue
+ {
+ get
+ {
+ return new SubstanceAmount(double.MaxValue);
+ }
+ }
+
+ ///
+ /// Represents the smallest possible value of SubstanceAmount
+ ///
+ public static SubstanceAmount MinValue
+ {
+ get
+ {
+ return new SubstanceAmount(double.MinValue);
+ }
+ }
+ }
+}
diff --git a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs
index 9582a43b3a..e31b8ad24e 100644
--- a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs
+++ b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs
@@ -90,6 +90,80 @@ private static readonly ReadOnlyCollection DefaultLocalization
new AbbreviationsForCulture("en-US", "nm/s²"),
}),
}),
+ new UnitLocalization(typeof (AmountOfSubstanceUnit),
+ new[]
+ {
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.Centimole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "cmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.CentipoundMole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "clbmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.Decimole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "dmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.DecipoundMole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "dlbmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.Kilomole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "kmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.KilopoundMole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "klbmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.Micromole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "µmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.MicropoundMole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "µlbmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.Millimole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "mmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.MillipoundMole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "mlbmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.Mole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "mol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.Nanomole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "nmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.NanopoundMole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "nlbmol"),
+ }),
+ new CulturesForEnumValue((int) AmountOfSubstanceUnit.PoundMole,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "lbmol"),
+ }),
+ }),
new UnitLocalization(typeof (AmplitudeRatioUnit),
new[]
{
diff --git a/UnitsNet/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs
new file mode 100644
index 0000000000..0394bca7fe
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs
@@ -0,0 +1,60 @@
+//------------------------------------------------------------------------------
+//
+// 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\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2007 Andreas Gullberg Larsen (angularsen@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+// ReSharper disable once CheckNamespace
+namespace UnitsNet.Units
+{
+ public enum AmountOfSubstanceUnit
+ {
+ Undefined = 0,
+ Centimole,
+ CentipoundMole,
+ Decimole,
+ DecipoundMole,
+ Kilomole,
+ KilopoundMole,
+ Micromole,
+ MicropoundMole,
+ Millimole,
+ MillipoundMole,
+ Mole,
+ Nanomole,
+ NanopoundMole,
+ PoundMole,
+ }
+}
diff --git a/UnitsNet/UnitDefinitions/AmountOfSubstance.json b/UnitsNet/UnitDefinitions/AmountOfSubstance.json
new file mode 100644
index 0000000000..2d26baf98e
--- /dev/null
+++ b/UnitsNet/UnitDefinitions/AmountOfSubstance.json
@@ -0,0 +1,33 @@
+{
+ "Name": "AmountOfSubstance",
+ "BaseUnit": "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.",
+ "Units": [
+ {
+ "SingularName": "Mole",
+ "PluralName": "Moles",
+ "FromUnitToBaseFunc": "x",
+ "FromBaseToUnitFunc": "x",
+ "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "mol" ]
+ }
+ ]
+ },
+ {
+ "SingularName": "PoundMole",
+ "PluralName": "PoundMoles",
+ "FromUnitToBaseFunc": "x*453.59237",
+ "FromBaseToUnitFunc": "x/453.59237",
+ "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "lbmol" ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file