diff --git a/UnitsNet.Tests/CustomCode/EntropyTests.cs b/UnitsNet.Tests/CustomCode/EntropyTests.cs new file mode 100644 index 0000000000..927079ddce --- /dev/null +++ b/UnitsNet.Tests/CustomCode/EntropyTests.cs @@ -0,0 +1,57 @@ +//------------------------------------------------------------------------------ +// +// 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 EntropyTests : EntropyTestsBase + { + protected override double CaloriesPerKelvinInOneJoulePerKelvin => 0.239006; + protected override double JoulesPerDegreeCelsiusInOneJoulePerKelvin => 1e0; + protected override double JoulesPerKelvinInOneJoulePerKelvin => 1e0; + protected override double KilocaloriesPerKelvinInOneJoulePerKelvin => 0.000239006; + protected override double KilojoulesPerDegreeCelsiusInOneJoulePerKelvin => 1e-3; + protected override double KilojoulesPerKelvinInOneJoulePerKelvin => 1e-3; + protected override double MegajoulesPerKelvinInOneJoulePerKelvin => 1e-6; + } +} diff --git a/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs new file mode 100644 index 0000000000..2006a0ee81 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.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/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 Entropy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class EntropyTestsBase + { + protected abstract double CaloriesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double JoulesPerDegreeCelsiusInOneJoulePerKelvin { get; } + protected abstract double JoulesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double KilocaloriesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double KilojoulesPerDegreeCelsiusInOneJoulePerKelvin { get; } + protected abstract double KilojoulesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double MegajoulesPerKelvinInOneJoulePerKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CaloriesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double JoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double JoulesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerKelvinTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void JoulePerKelvinToEntropyUnits() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.CaloriesPerKelvin, CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.JoulesPerDegreeCelsius, JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(KilocaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.KilocaloriesPerKelvin, KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(KilojoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.KilojoulesPerDegreeCelsius, KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(KilojoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.KilojoulesPerKelvin, KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(MegajoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.MegajoulesPerKelvin, MegajoulesPerKelvinTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.CaloriePerKelvin).CaloriesPerKelvin, CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.JoulePerDegreeCelsius).JoulesPerDegreeCelsius, JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.JoulePerKelvin).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.KilocaloriePerKelvin).KilocaloriesPerKelvin, KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.KilojoulePerDegreeCelsius).KilojoulesPerDegreeCelsius, KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.KilojoulePerKelvin).KilojoulesPerKelvin, KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.MegajoulePerKelvin).MegajoulesPerKelvin, MegajoulesPerKelvinTolerance); + } + + [Fact] + public void As() + { + var jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.CaloriePerKelvin), CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.JoulePerDegreeCelsius), JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.JoulePerKelvin), JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(KilocaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.KilocaloriePerKelvin), KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(KilojoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.KilojoulePerDegreeCelsius), KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(KilojoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.KilojoulePerKelvin), KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(MegajoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.MegajoulePerKelvin), MegajoulesPerKelvinTolerance); + } + + [Fact] + public void ConversionRoundTrip() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(1, Entropy.FromCaloriesPerKelvin(jouleperkelvin.CaloriesPerKelvin).JoulesPerKelvin, CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromJoulesPerDegreeCelsius(jouleperkelvin.JoulesPerDegreeCelsius).JoulesPerKelvin, JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.FromJoulesPerKelvin(jouleperkelvin.JoulesPerKelvin).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilocaloriesPerKelvin(jouleperkelvin.KilocaloriesPerKelvin).JoulesPerKelvin, KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerDegreeCelsius(jouleperkelvin.KilojoulesPerDegreeCelsius).JoulesPerKelvin, KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerKelvin(jouleperkelvin.KilojoulesPerKelvin).JoulesPerKelvin, KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromMegajoulesPerKelvin(jouleperkelvin.MegajoulesPerKelvin).JoulesPerKelvin, MegajoulesPerKelvinTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Entropy v = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(-1, -v.JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(3)-v).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (v + v).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(10, (v*10).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(10, (10*v).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(10)/5).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, Entropy.FromJoulesPerKelvin(10)/Entropy.FromJoulesPerKelvin(5), JoulesPerKelvinTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Entropy oneJoulePerKelvin = Entropy.FromJoulesPerKelvin(1); + Entropy twoJoulesPerKelvin = Entropy.FromJoulesPerKelvin(2); + + Assert.True(oneJoulePerKelvin < twoJoulesPerKelvin); + Assert.True(oneJoulePerKelvin <= twoJoulesPerKelvin); + Assert.True(twoJoulesPerKelvin > oneJoulePerKelvin); + Assert.True(twoJoulesPerKelvin >= oneJoulePerKelvin); + + Assert.False(oneJoulePerKelvin > twoJoulesPerKelvin); + Assert.False(oneJoulePerKelvin >= twoJoulesPerKelvin); + Assert.False(twoJoulesPerKelvin < oneJoulePerKelvin); + Assert.False(twoJoulesPerKelvin <= oneJoulePerKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.Equal(0, jouleperkelvin.CompareTo(jouleperkelvin)); + Assert.True(jouleperkelvin.CompareTo(Entropy.Zero) > 0); + Assert.True(Entropy.Zero.CompareTo(jouleperkelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.Throws(() => jouleperkelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.Throws(() => jouleperkelvin.CompareTo(null)); + } + + + [Fact] + public void EqualityOperators() + { + Entropy a = Entropy.FromJoulesPerKelvin(1); + Entropy b = Entropy.FromJoulesPerKelvin(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() + { + Entropy v = Entropy.FromJoulesPerKelvin(1); + Assert.True(v.Equals(Entropy.FromJoulesPerKelvin(1))); + Assert.False(v.Equals(Entropy.Zero)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.False(jouleperkelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.False(jouleperkelvin.Equals(null)); + } + } +} diff --git a/UnitsNet/GeneratedCode/Extensions/Number/NumberToEntropyExtensions.g.cs b/UnitsNet/GeneratedCode/Extensions/Number/NumberToEntropyExtensions.g.cs new file mode 100644 index 0000000000..88d7e49c8d --- /dev/null +++ b/UnitsNet/GeneratedCode/Extensions/Number/NumberToEntropyExtensions.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/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.NumberToEntropy +{ + public static class NumberToEntropyExtensions + { + #region CaloriePerKelvin + + /// + public static Entropy CaloriesPerKelvin(this int value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy? CaloriesPerKelvin(this int? value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy CaloriesPerKelvin(this long value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy? CaloriesPerKelvin(this long? value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy CaloriesPerKelvin(this double value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy? CaloriesPerKelvin(this double? value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy CaloriesPerKelvin(this float value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy? CaloriesPerKelvin(this float? value) => Entropy.FromCaloriesPerKelvin(value); + + /// + public static Entropy CaloriesPerKelvin(this decimal value) => Entropy.FromCaloriesPerKelvin(Convert.ToDouble(value)); + + /// + public static Entropy? CaloriesPerKelvin(this decimal? value) => Entropy.FromCaloriesPerKelvin(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region JoulePerDegreeCelsius + + /// + public static Entropy JoulesPerDegreeCelsius(this int value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy? JoulesPerDegreeCelsius(this int? value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy JoulesPerDegreeCelsius(this long value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy? JoulesPerDegreeCelsius(this long? value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy JoulesPerDegreeCelsius(this double value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy? JoulesPerDegreeCelsius(this double? value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy JoulesPerDegreeCelsius(this float value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy? JoulesPerDegreeCelsius(this float? value) => Entropy.FromJoulesPerDegreeCelsius(value); + + /// + public static Entropy JoulesPerDegreeCelsius(this decimal value) => Entropy.FromJoulesPerDegreeCelsius(Convert.ToDouble(value)); + + /// + public static Entropy? JoulesPerDegreeCelsius(this decimal? value) => Entropy.FromJoulesPerDegreeCelsius(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region JoulePerKelvin + + /// + public static Entropy JoulesPerKelvin(this int value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy? JoulesPerKelvin(this int? value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy JoulesPerKelvin(this long value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy? JoulesPerKelvin(this long? value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy JoulesPerKelvin(this double value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy? JoulesPerKelvin(this double? value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy JoulesPerKelvin(this float value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy? JoulesPerKelvin(this float? value) => Entropy.FromJoulesPerKelvin(value); + + /// + public static Entropy JoulesPerKelvin(this decimal value) => Entropy.FromJoulesPerKelvin(Convert.ToDouble(value)); + + /// + public static Entropy? JoulesPerKelvin(this decimal? value) => Entropy.FromJoulesPerKelvin(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region KilocaloriePerKelvin + + /// + public static Entropy KilocaloriesPerKelvin(this int value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy? KilocaloriesPerKelvin(this int? value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy KilocaloriesPerKelvin(this long value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy? KilocaloriesPerKelvin(this long? value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy KilocaloriesPerKelvin(this double value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy? KilocaloriesPerKelvin(this double? value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy KilocaloriesPerKelvin(this float value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy? KilocaloriesPerKelvin(this float? value) => Entropy.FromKilocaloriesPerKelvin(value); + + /// + public static Entropy KilocaloriesPerKelvin(this decimal value) => Entropy.FromKilocaloriesPerKelvin(Convert.ToDouble(value)); + + /// + public static Entropy? KilocaloriesPerKelvin(this decimal? value) => Entropy.FromKilocaloriesPerKelvin(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region KilojoulePerDegreeCelsius + + /// + public static Entropy KilojoulesPerDegreeCelsius(this int value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy? KilojoulesPerDegreeCelsius(this int? value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy KilojoulesPerDegreeCelsius(this long value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy? KilojoulesPerDegreeCelsius(this long? value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy KilojoulesPerDegreeCelsius(this double value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy? KilojoulesPerDegreeCelsius(this double? value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy KilojoulesPerDegreeCelsius(this float value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy? KilojoulesPerDegreeCelsius(this float? value) => Entropy.FromKilojoulesPerDegreeCelsius(value); + + /// + public static Entropy KilojoulesPerDegreeCelsius(this decimal value) => Entropy.FromKilojoulesPerDegreeCelsius(Convert.ToDouble(value)); + + /// + public static Entropy? KilojoulesPerDegreeCelsius(this decimal? value) => Entropy.FromKilojoulesPerDegreeCelsius(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region KilojoulePerKelvin + + /// + public static Entropy KilojoulesPerKelvin(this int value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy? KilojoulesPerKelvin(this int? value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy KilojoulesPerKelvin(this long value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy? KilojoulesPerKelvin(this long? value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy KilojoulesPerKelvin(this double value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy? KilojoulesPerKelvin(this double? value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy KilojoulesPerKelvin(this float value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy? KilojoulesPerKelvin(this float? value) => Entropy.FromKilojoulesPerKelvin(value); + + /// + public static Entropy KilojoulesPerKelvin(this decimal value) => Entropy.FromKilojoulesPerKelvin(Convert.ToDouble(value)); + + /// + public static Entropy? KilojoulesPerKelvin(this decimal? value) => Entropy.FromKilojoulesPerKelvin(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region MegajoulePerKelvin + + /// + public static Entropy MegajoulesPerKelvin(this int value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy? MegajoulesPerKelvin(this int? value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy MegajoulesPerKelvin(this long value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy? MegajoulesPerKelvin(this long? value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy MegajoulesPerKelvin(this double value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy? MegajoulesPerKelvin(this double? value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy MegajoulesPerKelvin(this float value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy? MegajoulesPerKelvin(this float? value) => Entropy.FromMegajoulesPerKelvin(value); + + /// + public static Entropy MegajoulesPerKelvin(this decimal value) => Entropy.FromMegajoulesPerKelvin(Convert.ToDouble(value)); + + /// + public static Entropy? MegajoulesPerKelvin(this decimal? value) => Entropy.FromMegajoulesPerKelvin(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + } +} +#endif diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs new file mode 100644 index 0000000000..a49774c9c8 --- /dev/null +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -0,0 +1,1392 @@ +//------------------------------------------------------------------------------ +// +// 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 +{ + /// + /// + /// + // 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 Entropy +#else + public partial struct Entropy : IComparable, IComparable +#endif + { + /// + /// Base unit of Entropy. + /// + private readonly double _joulesPerKelvin; + + // Windows Runtime Component requires a default constructor +#if WINDOWS_UWP + public Entropy() : this(0) + { + } +#endif + + public Entropy(double joulesperkelvin) + { + _joulesPerKelvin = Convert.ToDouble(joulesperkelvin); + } + + // 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 + Entropy(long joulesperkelvin) + { + _joulesPerKelvin = Convert.ToDouble(joulesperkelvin); + } + + // 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 + Entropy(decimal joulesperkelvin) + { + _joulesPerKelvin = Convert.ToDouble(joulesperkelvin); + } + + #region Properties + + /// + /// The of this quantity. + /// + public static QuantityType QuantityType => QuantityType.Entropy; + + /// + /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value. + /// + public static EntropyUnit BaseUnit + { + get { return EntropyUnit.JoulePerKelvin; } + } + + /// + /// All units of measurement for the Entropy quantity. + /// + public static EntropyUnit[] Units { get; } = Enum.GetValues(typeof(EntropyUnit)).Cast().ToArray(); + + /// + /// Get Entropy in CaloriesPerKelvin. + /// + public double CaloriesPerKelvin + { + get { return _joulesPerKelvin/4.184; } + } + + /// + /// Get Entropy in JoulesPerDegreeCelsius. + /// + public double JoulesPerDegreeCelsius + { + get { return _joulesPerKelvin; } + } + + /// + /// Get Entropy in JoulesPerKelvin. + /// + public double JoulesPerKelvin + { + get { return _joulesPerKelvin; } + } + + /// + /// Get Entropy in KilocaloriesPerKelvin. + /// + public double KilocaloriesPerKelvin + { + get { return (_joulesPerKelvin/4.184) / 1e3d; } + } + + /// + /// Get Entropy in KilojoulesPerDegreeCelsius. + /// + public double KilojoulesPerDegreeCelsius + { + get { return (_joulesPerKelvin) / 1e3d; } + } + + /// + /// Get Entropy in KilojoulesPerKelvin. + /// + public double KilojoulesPerKelvin + { + get { return (_joulesPerKelvin) / 1e3d; } + } + + /// + /// Get Entropy in MegajoulesPerKelvin. + /// + public double MegajoulesPerKelvin + { + get { return (_joulesPerKelvin) / 1e6d; } + } + + #endregion + + #region Static + + public static Entropy Zero + { + get { return new Entropy(); } + } + + /// + /// Get Entropy from CaloriesPerKelvin. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static Entropy FromCaloriesPerKelvin(double caloriesperkelvin) + { + return new Entropy(caloriesperkelvin*4.184); + } + + /// + /// Get Entropy from CaloriesPerKelvin. + /// + public static Entropy FromCaloriesPerKelvin(int caloriesperkelvin) + { + return new Entropy(caloriesperkelvin*4.184); + } + + /// + /// Get Entropy from CaloriesPerKelvin. + /// + public static Entropy FromCaloriesPerKelvin(long caloriesperkelvin) + { + return new Entropy(caloriesperkelvin*4.184); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get Entropy from CaloriesPerKelvin of type decimal. + /// + public static Entropy FromCaloriesPerKelvin(decimal caloriesperkelvin) + { + return new Entropy(Convert.ToDouble(caloriesperkelvin)*4.184); + } +#endif + + /// + /// Get Entropy from JoulesPerDegreeCelsius. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static Entropy FromJoulesPerDegreeCelsius(double joulesperdegreecelsius) + { + return new Entropy(joulesperdegreecelsius); + } + + /// + /// Get Entropy from JoulesPerDegreeCelsius. + /// + public static Entropy FromJoulesPerDegreeCelsius(int joulesperdegreecelsius) + { + return new Entropy(joulesperdegreecelsius); + } + + /// + /// Get Entropy from JoulesPerDegreeCelsius. + /// + public static Entropy FromJoulesPerDegreeCelsius(long joulesperdegreecelsius) + { + return new Entropy(joulesperdegreecelsius); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get Entropy from JoulesPerDegreeCelsius of type decimal. + /// + public static Entropy FromJoulesPerDegreeCelsius(decimal joulesperdegreecelsius) + { + return new Entropy(Convert.ToDouble(joulesperdegreecelsius)); + } +#endif + + /// + /// Get Entropy from JoulesPerKelvin. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static Entropy FromJoulesPerKelvin(double joulesperkelvin) + { + return new Entropy(joulesperkelvin); + } + + /// + /// Get Entropy from JoulesPerKelvin. + /// + public static Entropy FromJoulesPerKelvin(int joulesperkelvin) + { + return new Entropy(joulesperkelvin); + } + + /// + /// Get Entropy from JoulesPerKelvin. + /// + public static Entropy FromJoulesPerKelvin(long joulesperkelvin) + { + return new Entropy(joulesperkelvin); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get Entropy from JoulesPerKelvin of type decimal. + /// + public static Entropy FromJoulesPerKelvin(decimal joulesperkelvin) + { + return new Entropy(Convert.ToDouble(joulesperkelvin)); + } +#endif + + /// + /// Get Entropy from KilocaloriesPerKelvin. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static Entropy FromKilocaloriesPerKelvin(double kilocaloriesperkelvin) + { + return new Entropy((kilocaloriesperkelvin*4.184) * 1e3d); + } + + /// + /// Get Entropy from KilocaloriesPerKelvin. + /// + public static Entropy FromKilocaloriesPerKelvin(int kilocaloriesperkelvin) + { + return new Entropy((kilocaloriesperkelvin*4.184) * 1e3d); + } + + /// + /// Get Entropy from KilocaloriesPerKelvin. + /// + public static Entropy FromKilocaloriesPerKelvin(long kilocaloriesperkelvin) + { + return new Entropy((kilocaloriesperkelvin*4.184) * 1e3d); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get Entropy from KilocaloriesPerKelvin of type decimal. + /// + public static Entropy FromKilocaloriesPerKelvin(decimal kilocaloriesperkelvin) + { + return new Entropy((Convert.ToDouble(kilocaloriesperkelvin)*4.184) * 1e3d); + } +#endif + + /// + /// Get Entropy from KilojoulesPerDegreeCelsius. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static Entropy FromKilojoulesPerDegreeCelsius(double kilojoulesperdegreecelsius) + { + return new Entropy((kilojoulesperdegreecelsius) * 1e3d); + } + + /// + /// Get Entropy from KilojoulesPerDegreeCelsius. + /// + public static Entropy FromKilojoulesPerDegreeCelsius(int kilojoulesperdegreecelsius) + { + return new Entropy((kilojoulesperdegreecelsius) * 1e3d); + } + + /// + /// Get Entropy from KilojoulesPerDegreeCelsius. + /// + public static Entropy FromKilojoulesPerDegreeCelsius(long kilojoulesperdegreecelsius) + { + return new Entropy((kilojoulesperdegreecelsius) * 1e3d); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get Entropy from KilojoulesPerDegreeCelsius of type decimal. + /// + public static Entropy FromKilojoulesPerDegreeCelsius(decimal kilojoulesperdegreecelsius) + { + return new Entropy((Convert.ToDouble(kilojoulesperdegreecelsius)) * 1e3d); + } +#endif + + /// + /// Get Entropy from KilojoulesPerKelvin. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static Entropy FromKilojoulesPerKelvin(double kilojoulesperkelvin) + { + return new Entropy((kilojoulesperkelvin) * 1e3d); + } + + /// + /// Get Entropy from KilojoulesPerKelvin. + /// + public static Entropy FromKilojoulesPerKelvin(int kilojoulesperkelvin) + { + return new Entropy((kilojoulesperkelvin) * 1e3d); + } + + /// + /// Get Entropy from KilojoulesPerKelvin. + /// + public static Entropy FromKilojoulesPerKelvin(long kilojoulesperkelvin) + { + return new Entropy((kilojoulesperkelvin) * 1e3d); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get Entropy from KilojoulesPerKelvin of type decimal. + /// + public static Entropy FromKilojoulesPerKelvin(decimal kilojoulesperkelvin) + { + return new Entropy((Convert.ToDouble(kilojoulesperkelvin)) * 1e3d); + } +#endif + + /// + /// Get Entropy from MegajoulesPerKelvin. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static Entropy FromMegajoulesPerKelvin(double megajoulesperkelvin) + { + return new Entropy((megajoulesperkelvin) * 1e6d); + } + + /// + /// Get Entropy from MegajoulesPerKelvin. + /// + public static Entropy FromMegajoulesPerKelvin(int megajoulesperkelvin) + { + return new Entropy((megajoulesperkelvin) * 1e6d); + } + + /// + /// Get Entropy from MegajoulesPerKelvin. + /// + public static Entropy FromMegajoulesPerKelvin(long megajoulesperkelvin) + { + return new Entropy((megajoulesperkelvin) * 1e6d); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get Entropy from MegajoulesPerKelvin of type decimal. + /// + public static Entropy FromMegajoulesPerKelvin(decimal megajoulesperkelvin) + { + return new Entropy((Convert.ToDouble(megajoulesperkelvin)) * 1e6d); + } +#endif + + // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx +#if !WINDOWS_UWP + /// + /// Get nullable Entropy from nullable CaloriesPerKelvin. + /// + public static Entropy? FromCaloriesPerKelvin(double? caloriesperkelvin) + { + if (caloriesperkelvin.HasValue) + { + return FromCaloriesPerKelvin(caloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable CaloriesPerKelvin. + /// + public static Entropy? FromCaloriesPerKelvin(int? caloriesperkelvin) + { + if (caloriesperkelvin.HasValue) + { + return FromCaloriesPerKelvin(caloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable CaloriesPerKelvin. + /// + public static Entropy? FromCaloriesPerKelvin(long? caloriesperkelvin) + { + if (caloriesperkelvin.HasValue) + { + return FromCaloriesPerKelvin(caloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from CaloriesPerKelvin of type decimal. + /// + public static Entropy? FromCaloriesPerKelvin(decimal? caloriesperkelvin) + { + if (caloriesperkelvin.HasValue) + { + return FromCaloriesPerKelvin(caloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable JoulesPerDegreeCelsius. + /// + public static Entropy? FromJoulesPerDegreeCelsius(double? joulesperdegreecelsius) + { + if (joulesperdegreecelsius.HasValue) + { + return FromJoulesPerDegreeCelsius(joulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable JoulesPerDegreeCelsius. + /// + public static Entropy? FromJoulesPerDegreeCelsius(int? joulesperdegreecelsius) + { + if (joulesperdegreecelsius.HasValue) + { + return FromJoulesPerDegreeCelsius(joulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable JoulesPerDegreeCelsius. + /// + public static Entropy? FromJoulesPerDegreeCelsius(long? joulesperdegreecelsius) + { + if (joulesperdegreecelsius.HasValue) + { + return FromJoulesPerDegreeCelsius(joulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from JoulesPerDegreeCelsius of type decimal. + /// + public static Entropy? FromJoulesPerDegreeCelsius(decimal? joulesperdegreecelsius) + { + if (joulesperdegreecelsius.HasValue) + { + return FromJoulesPerDegreeCelsius(joulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable JoulesPerKelvin. + /// + public static Entropy? FromJoulesPerKelvin(double? joulesperkelvin) + { + if (joulesperkelvin.HasValue) + { + return FromJoulesPerKelvin(joulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable JoulesPerKelvin. + /// + public static Entropy? FromJoulesPerKelvin(int? joulesperkelvin) + { + if (joulesperkelvin.HasValue) + { + return FromJoulesPerKelvin(joulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable JoulesPerKelvin. + /// + public static Entropy? FromJoulesPerKelvin(long? joulesperkelvin) + { + if (joulesperkelvin.HasValue) + { + return FromJoulesPerKelvin(joulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from JoulesPerKelvin of type decimal. + /// + public static Entropy? FromJoulesPerKelvin(decimal? joulesperkelvin) + { + if (joulesperkelvin.HasValue) + { + return FromJoulesPerKelvin(joulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilocaloriesPerKelvin. + /// + public static Entropy? FromKilocaloriesPerKelvin(double? kilocaloriesperkelvin) + { + if (kilocaloriesperkelvin.HasValue) + { + return FromKilocaloriesPerKelvin(kilocaloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilocaloriesPerKelvin. + /// + public static Entropy? FromKilocaloriesPerKelvin(int? kilocaloriesperkelvin) + { + if (kilocaloriesperkelvin.HasValue) + { + return FromKilocaloriesPerKelvin(kilocaloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilocaloriesPerKelvin. + /// + public static Entropy? FromKilocaloriesPerKelvin(long? kilocaloriesperkelvin) + { + if (kilocaloriesperkelvin.HasValue) + { + return FromKilocaloriesPerKelvin(kilocaloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from KilocaloriesPerKelvin of type decimal. + /// + public static Entropy? FromKilocaloriesPerKelvin(decimal? kilocaloriesperkelvin) + { + if (kilocaloriesperkelvin.HasValue) + { + return FromKilocaloriesPerKelvin(kilocaloriesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilojoulesPerDegreeCelsius. + /// + public static Entropy? FromKilojoulesPerDegreeCelsius(double? kilojoulesperdegreecelsius) + { + if (kilojoulesperdegreecelsius.HasValue) + { + return FromKilojoulesPerDegreeCelsius(kilojoulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilojoulesPerDegreeCelsius. + /// + public static Entropy? FromKilojoulesPerDegreeCelsius(int? kilojoulesperdegreecelsius) + { + if (kilojoulesperdegreecelsius.HasValue) + { + return FromKilojoulesPerDegreeCelsius(kilojoulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilojoulesPerDegreeCelsius. + /// + public static Entropy? FromKilojoulesPerDegreeCelsius(long? kilojoulesperdegreecelsius) + { + if (kilojoulesperdegreecelsius.HasValue) + { + return FromKilojoulesPerDegreeCelsius(kilojoulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from KilojoulesPerDegreeCelsius of type decimal. + /// + public static Entropy? FromKilojoulesPerDegreeCelsius(decimal? kilojoulesperdegreecelsius) + { + if (kilojoulesperdegreecelsius.HasValue) + { + return FromKilojoulesPerDegreeCelsius(kilojoulesperdegreecelsius.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilojoulesPerKelvin. + /// + public static Entropy? FromKilojoulesPerKelvin(double? kilojoulesperkelvin) + { + if (kilojoulesperkelvin.HasValue) + { + return FromKilojoulesPerKelvin(kilojoulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilojoulesPerKelvin. + /// + public static Entropy? FromKilojoulesPerKelvin(int? kilojoulesperkelvin) + { + if (kilojoulesperkelvin.HasValue) + { + return FromKilojoulesPerKelvin(kilojoulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable KilojoulesPerKelvin. + /// + public static Entropy? FromKilojoulesPerKelvin(long? kilojoulesperkelvin) + { + if (kilojoulesperkelvin.HasValue) + { + return FromKilojoulesPerKelvin(kilojoulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from KilojoulesPerKelvin of type decimal. + /// + public static Entropy? FromKilojoulesPerKelvin(decimal? kilojoulesperkelvin) + { + if (kilojoulesperkelvin.HasValue) + { + return FromKilojoulesPerKelvin(kilojoulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable MegajoulesPerKelvin. + /// + public static Entropy? FromMegajoulesPerKelvin(double? megajoulesperkelvin) + { + if (megajoulesperkelvin.HasValue) + { + return FromMegajoulesPerKelvin(megajoulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable MegajoulesPerKelvin. + /// + public static Entropy? FromMegajoulesPerKelvin(int? megajoulesperkelvin) + { + if (megajoulesperkelvin.HasValue) + { + return FromMegajoulesPerKelvin(megajoulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from nullable MegajoulesPerKelvin. + /// + public static Entropy? FromMegajoulesPerKelvin(long? megajoulesperkelvin) + { + if (megajoulesperkelvin.HasValue) + { + return FromMegajoulesPerKelvin(megajoulesperkelvin.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable Entropy from MegajoulesPerKelvin of type decimal. + /// + public static Entropy? FromMegajoulesPerKelvin(decimal? megajoulesperkelvin) + { + if (megajoulesperkelvin.HasValue) + { + return FromMegajoulesPerKelvin(megajoulesperkelvin.Value); + } + else + { + return null; + } + } + +#endif + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// Entropy unit value. + public static Entropy From(double val, EntropyUnit fromUnit) + { + switch (fromUnit) + { + case EntropyUnit.CaloriePerKelvin: + return FromCaloriesPerKelvin(val); + case EntropyUnit.JoulePerDegreeCelsius: + return FromJoulesPerDegreeCelsius(val); + case EntropyUnit.JoulePerKelvin: + return FromJoulesPerKelvin(val); + case EntropyUnit.KilocaloriePerKelvin: + return FromKilocaloriesPerKelvin(val); + case EntropyUnit.KilojoulePerDegreeCelsius: + return FromKilojoulesPerDegreeCelsius(val); + case EntropyUnit.KilojoulePerKelvin: + return FromKilojoulesPerKelvin(val); + case EntropyUnit.MegajoulePerKelvin: + return FromMegajoulesPerKelvin(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. + /// Entropy unit value. + public static Entropy? From(double? value, EntropyUnit fromUnit) + { + if (!value.HasValue) + { + return null; + } + switch (fromUnit) + { + case EntropyUnit.CaloriePerKelvin: + return FromCaloriesPerKelvin(value.Value); + case EntropyUnit.JoulePerDegreeCelsius: + return FromJoulesPerDegreeCelsius(value.Value); + case EntropyUnit.JoulePerKelvin: + return FromJoulesPerKelvin(value.Value); + case EntropyUnit.KilocaloriePerKelvin: + return FromKilocaloriesPerKelvin(value.Value); + case EntropyUnit.KilojoulePerDegreeCelsius: + return FromKilojoulesPerDegreeCelsius(value.Value); + case EntropyUnit.KilojoulePerKelvin: + return FromKilojoulesPerKelvin(value.Value); + case EntropyUnit.MegajoulePerKelvin: + return FromMegajoulesPerKelvin(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(EntropyUnit 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(EntropyUnit 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 Entropy operator -(Entropy right) + { + return new Entropy(-right._joulesPerKelvin); + } + + public static Entropy operator +(Entropy left, Entropy right) + { + return new Entropy(left._joulesPerKelvin + right._joulesPerKelvin); + } + + public static Entropy operator -(Entropy left, Entropy right) + { + return new Entropy(left._joulesPerKelvin - right._joulesPerKelvin); + } + + public static Entropy operator *(double left, Entropy right) + { + return new Entropy(left*right._joulesPerKelvin); + } + + public static Entropy operator *(Entropy left, double right) + { + return new Entropy(left._joulesPerKelvin*(double)right); + } + + public static Entropy operator /(Entropy left, double right) + { + return new Entropy(left._joulesPerKelvin/(double)right); + } + + public static double operator /(Entropy left, Entropy right) + { + return Convert.ToDouble(left._joulesPerKelvin/right._joulesPerKelvin); + } +#endif + + #endregion + + #region Equality / IComparable + + public int CompareTo(object obj) + { + if (obj == null) throw new ArgumentNullException("obj"); + if (!(obj is Entropy)) throw new ArgumentException("Expected type Entropy.", "obj"); + return CompareTo((Entropy) 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(Entropy other) + { + return _joulesPerKelvin.CompareTo(other._joulesPerKelvin); + } + + // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx +#if !WINDOWS_UWP + public static bool operator <=(Entropy left, Entropy right) + { + return left._joulesPerKelvin <= right._joulesPerKelvin; + } + + public static bool operator >=(Entropy left, Entropy right) + { + return left._joulesPerKelvin >= right._joulesPerKelvin; + } + + public static bool operator <(Entropy left, Entropy right) + { + return left._joulesPerKelvin < right._joulesPerKelvin; + } + + public static bool operator >(Entropy left, Entropy right) + { + return left._joulesPerKelvin > right._joulesPerKelvin; + } + + public static bool operator ==(Entropy left, Entropy right) + { + // ReSharper disable once CompareOfFloatsByEqualityOperator + return left._joulesPerKelvin == right._joulesPerKelvin; + } + + public static bool operator !=(Entropy left, Entropy right) + { + // ReSharper disable once CompareOfFloatsByEqualityOperator + return left._joulesPerKelvin != right._joulesPerKelvin; + } +#endif + + public override bool Equals(object obj) + { + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + + return _joulesPerKelvin.Equals(((Entropy) obj)._joulesPerKelvin); + } + + public override int GetHashCode() + { + return _joulesPerKelvin.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(EntropyUnit unit) + { + switch (unit) + { + case EntropyUnit.CaloriePerKelvin: + return CaloriesPerKelvin; + case EntropyUnit.JoulePerDegreeCelsius: + return JoulesPerDegreeCelsius; + case EntropyUnit.JoulePerKelvin: + return JoulesPerKelvin; + case EntropyUnit.KilocaloriePerKelvin: + return KilocaloriesPerKelvin; + case EntropyUnit.KilojoulePerDegreeCelsius: + return KilojoulesPerDegreeCelsius; + case EntropyUnit.KilojoulePerKelvin: + return KilojoulesPerKelvin; + case EntropyUnit.MegajoulePerKelvin: + return MegajoulesPerKelvin; + + 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 Entropy Parse(string str) + { + return Parse(str, null); + } + + /// + /// Parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// 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 Entropy 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); + EntropyUnit parsedUnit = ParseUnit(unit, formatProvider2); + return From(parsedValue, parsedUnit); + }, (x, y) => FromJoulesPerKelvin(x.JoulesPerKelvin + y.JoulesPerKelvin)); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// + /// Length.Parse("5.5 m", new CultureInfo("en-US")); + /// + public static bool TryParse([CanBeNull] string str, out Entropy result) + { + return TryParse(str, null, out result); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// 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 Entropy result) + { + try + { + result = Parse(str, culture); + return true; + } + catch + { + result = default(Entropy); + 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 EntropyUnit 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 EntropyUnit 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 EntropyUnit 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 == EntropyUnit.Undefined) + { + var newEx = new UnitsNetException("Error parsing string. The unit is not a recognized EntropyUnit."); + newEx.Data["input"] = str; + newEx.Data["formatprovider"] = formatProvider?.ToString() ?? "(null)"; + throw newEx; + } + + return unit; + } + + #endregion + + /// + /// Set the default unit used by ToString(). Default is JoulePerKelvin + /// + public static EntropyUnit ToStringDefaultUnit { get; set; } = EntropyUnit.JoulePerKelvin; + + /// + /// 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(EntropyUnit 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(EntropyUnit 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(EntropyUnit 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(EntropyUnit 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 Entropy + /// + public static Entropy MaxValue + { + get + { + return new Entropy(double.MaxValue); + } + } + + /// + /// Represents the smallest possible value of Entropy + /// + public static Entropy MinValue + { + get + { + return new Entropy(double.MinValue); + } + } + } +} diff --git a/UnitsNet/GeneratedCode/QuantityType.g.cs b/UnitsNet/GeneratedCode/QuantityType.g.cs index 83b20ab126..64aebec25d 100644 --- a/UnitsNet/GeneratedCode/QuantityType.g.cs +++ b/UnitsNet/GeneratedCode/QuantityType.g.cs @@ -66,6 +66,7 @@ public enum QuantityType ElectricPotentialDc, ElectricResistance, Energy, + Entropy, Flow, Force, ForceChangeRate, diff --git a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs index 9deefc4110..bbb254db90 100644 --- a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs +++ b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs @@ -917,6 +917,45 @@ private static readonly ReadOnlyCollection DefaultLocalization new AbbreviationsForCulture("en-US", "Вт/ч"), }), }), + new UnitLocalization(typeof (EntropyUnit), + new[] + { + new CulturesForEnumValue((int) EntropyUnit.CaloriePerKelvin, + new[] + { + new AbbreviationsForCulture("en-US", "cal/K"), + }), + new CulturesForEnumValue((int) EntropyUnit.JoulePerDegreeCelsius, + new[] + { + new AbbreviationsForCulture("en-US", "J/C"), + }), + new CulturesForEnumValue((int) EntropyUnit.JoulePerKelvin, + new[] + { + new AbbreviationsForCulture("en-US", "J/K"), + }), + new CulturesForEnumValue((int) EntropyUnit.KilocaloriePerKelvin, + new[] + { + new AbbreviationsForCulture("en-US", "kcal/K"), + }), + new CulturesForEnumValue((int) EntropyUnit.KilojoulePerDegreeCelsius, + new[] + { + new AbbreviationsForCulture("en-US", "kJ/C"), + }), + new CulturesForEnumValue((int) EntropyUnit.KilojoulePerKelvin, + new[] + { + new AbbreviationsForCulture("en-US", "kJ/K"), + }), + new CulturesForEnumValue((int) EntropyUnit.MegajoulePerKelvin, + new[] + { + new AbbreviationsForCulture("en-US", "MJ/K"), + }), + }), new UnitLocalization(typeof (FlowUnit), new[] { diff --git a/UnitsNet/GeneratedCode/Units/EntropyUnit.g.cs b/UnitsNet/GeneratedCode/Units/EntropyUnit.g.cs new file mode 100644 index 0000000000..065d751113 --- /dev/null +++ b/UnitsNet/GeneratedCode/Units/EntropyUnit.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/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 EntropyUnit + { + Undefined = 0, + CaloriePerKelvin, + JoulePerDegreeCelsius, + JoulePerKelvin, + KilocaloriePerKelvin, + KilojoulePerDegreeCelsius, + KilojoulePerKelvin, + MegajoulePerKelvin, + } +} diff --git a/UnitsNet/UnitDefinitions/Entropy.json b/UnitsNet/UnitDefinitions/Entropy.json new file mode 100644 index 0000000000..22a5fa5ec1 --- /dev/null +++ b/UnitsNet/UnitDefinitions/Entropy.json @@ -0,0 +1,46 @@ +{ + "Name": "Entropy", + "BaseUnit": "JoulePerKelvin", + "XmlDoc": "Entropy is an important concept in the branch of science known as thermodynamics. The idea of \"irreversibility\" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J K−1) in the International System of Units", + "Units": [ + { + "SingularName": "JoulePerKelvin", + "PluralName": "JoulesPerKelvin", + "FromUnitToBaseFunc": "x", + "FromBaseToUnitFunc": "x", + "Prefixes": [ "Kilo", "Mega" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "J/K" ] + } + ] + }, + { + "SingularName": "CaloriePerKelvin", + "PluralName": "CaloriesPerKelvin", + "FromUnitToBaseFunc": "x*4.184", + "FromBaseToUnitFunc": "x/4.184", + "Prefixes": [ "Kilo" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "cal/K" ] + } + ] + }, + { + "SingularName": "JoulePerDegreeCelsius", + "PluralName": "JoulesPerDegreeCelsius", + "FromUnitToBaseFunc": "x", + "FromBaseToUnitFunc": "x", + "Prefixes": [ "Kilo" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "J/C" ] + } + ] + } + ] +}