From d8c9920bbbf7ff0e9fceb2d2a5cdcc8ee2680172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Tun=C3=A7er?= Date: Thu, 9 Nov 2017 15:53:29 +0300 Subject: [PATCH] added new quantity: lapserate --- UnitsNet.Tests/CustomCode/LapseRateTests.cs | 52 ++ .../GeneratedCode/LapseRateTestsBase.g.cs | 185 ++++ .../Number/NumberToLapseRateExtensions.g.cs | 117 +++ .../GeneratedCode/Quantities/LapseRate.g.cs | 832 ++++++++++++++++++ .../Quantities/MolarEntropy.g.cs | 2 +- UnitsNet/GeneratedCode/QuantityType.g.cs | 3 +- .../GeneratedCode/UnitSystem.Default.g.cs | 44 +- .../GeneratedCode/Units/LapseRateUnit.g.cs | 48 + UnitsNet/UnitDefinitions/LapseRate.json | 20 + 9 files changed, 1287 insertions(+), 16 deletions(-) create mode 100644 UnitsNet.Tests/CustomCode/LapseRateTests.cs create mode 100644 UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs create mode 100644 UnitsNet/GeneratedCode/Extensions/Number/NumberToLapseRateExtensions.g.cs create mode 100644 UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs create mode 100644 UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs create mode 100644 UnitsNet/UnitDefinitions/LapseRate.json diff --git a/UnitsNet.Tests/CustomCode/LapseRateTests.cs b/UnitsNet.Tests/CustomCode/LapseRateTests.cs new file mode 100644 index 0000000000..3846fc6a26 --- /dev/null +++ b/UnitsNet.Tests/CustomCode/LapseRateTests.cs @@ -0,0 +1,52 @@ +//------------------------------------------------------------------------------ +// +// 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 LapseRateTests : LapseRateTestsBase + { + protected override double DegreesCelciusPerMeterInOneDegreeCelsiusPerMeter => 1e0; + protected override double KilodegreesCelciusPerMeterInOneDegreeCelsiusPerMeter => 1e-3; + } +} diff --git a/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs new file mode 100644 index 0000000000..1cfdcb35d7 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs @@ -0,0 +1,185 @@ +//------------------------------------------------------------------------------ +// +// 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 LapseRate. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class LapseRateTestsBase + { + protected abstract double DegreesCelciusPerMeterInOneDegreeCelsiusPerMeter { get; } + protected abstract double KilodegreesCelciusPerMeterInOneDegreeCelsiusPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DegreesCelciusPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilodegreesCelciusPerMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void DegreeCelsiusPerMeterToLapseRateUnits() + { + LapseRate degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + AssertEx.EqualTolerance(DegreesCelciusPerMeterInOneDegreeCelsiusPerMeter, degreecelsiuspermeter.DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(KilodegreesCelciusPerMeterInOneDegreeCelsiusPerMeter, degreecelsiuspermeter.KilodegreesCelciusPerMeter, KilodegreesCelciusPerMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, LapseRate.From(1, LapseRateUnit.DegreeCelsiusPerMeter).DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(1, LapseRate.From(1, LapseRateUnit.KilodegreeCelsiusPerMeter).KilodegreesCelciusPerMeter, KilodegreesCelciusPerMeterTolerance); + } + + [Fact] + public void As() + { + var degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + AssertEx.EqualTolerance(DegreesCelciusPerMeterInOneDegreeCelsiusPerMeter, degreecelsiuspermeter.As(LapseRateUnit.DegreeCelsiusPerMeter), DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(KilodegreesCelciusPerMeterInOneDegreeCelsiusPerMeter, degreecelsiuspermeter.As(LapseRateUnit.KilodegreeCelsiusPerMeter), KilodegreesCelciusPerMeterTolerance); + } + + [Fact] + public void ConversionRoundTrip() + { + LapseRate degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + AssertEx.EqualTolerance(1, LapseRate.FromDegreesCelciusPerMeter(degreecelsiuspermeter.DegreesCelciusPerMeter).DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(1, LapseRate.FromKilodegreesCelciusPerMeter(degreecelsiuspermeter.KilodegreesCelciusPerMeter).DegreesCelciusPerMeter, KilodegreesCelciusPerMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + LapseRate v = LapseRate.FromDegreesCelciusPerMeter(1); + AssertEx.EqualTolerance(-1, -v.DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerMeter(3)-v).DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerMeter(10)/5).DegreesCelciusPerMeter, DegreesCelciusPerMeterTolerance); + AssertEx.EqualTolerance(2, LapseRate.FromDegreesCelciusPerMeter(10)/LapseRate.FromDegreesCelciusPerMeter(5), DegreesCelciusPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + LapseRate oneDegreeCelsiusPerMeter = LapseRate.FromDegreesCelciusPerMeter(1); + LapseRate twoDegreesCelciusPerMeter = LapseRate.FromDegreesCelciusPerMeter(2); + + Assert.True(oneDegreeCelsiusPerMeter < twoDegreesCelciusPerMeter); + Assert.True(oneDegreeCelsiusPerMeter <= twoDegreesCelciusPerMeter); + Assert.True(twoDegreesCelciusPerMeter > oneDegreeCelsiusPerMeter); + Assert.True(twoDegreesCelciusPerMeter >= oneDegreeCelsiusPerMeter); + + Assert.False(oneDegreeCelsiusPerMeter > twoDegreesCelciusPerMeter); + Assert.False(oneDegreeCelsiusPerMeter >= twoDegreesCelciusPerMeter); + Assert.False(twoDegreesCelciusPerMeter < oneDegreeCelsiusPerMeter); + Assert.False(twoDegreesCelciusPerMeter <= oneDegreeCelsiusPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + LapseRate degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + Assert.Equal(0, degreecelsiuspermeter.CompareTo(degreecelsiuspermeter)); + Assert.True(degreecelsiuspermeter.CompareTo(LapseRate.Zero) > 0); + Assert.True(LapseRate.Zero.CompareTo(degreecelsiuspermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + LapseRate degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + Assert.Throws(() => degreecelsiuspermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + LapseRate degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + Assert.Throws(() => degreecelsiuspermeter.CompareTo(null)); + } + + + [Fact] + public void EqualityOperators() + { + LapseRate a = LapseRate.FromDegreesCelciusPerMeter(1); + LapseRate b = LapseRate.FromDegreesCelciusPerMeter(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() + { + LapseRate v = LapseRate.FromDegreesCelciusPerMeter(1); + Assert.True(v.Equals(LapseRate.FromDegreesCelciusPerMeter(1))); + Assert.False(v.Equals(LapseRate.Zero)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + LapseRate degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + Assert.False(degreecelsiuspermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + LapseRate degreecelsiuspermeter = LapseRate.FromDegreesCelciusPerMeter(1); + Assert.False(degreecelsiuspermeter.Equals(null)); + } + } +} diff --git a/UnitsNet/GeneratedCode/Extensions/Number/NumberToLapseRateExtensions.g.cs b/UnitsNet/GeneratedCode/Extensions/Number/NumberToLapseRateExtensions.g.cs new file mode 100644 index 0000000000..eab1eb9deb --- /dev/null +++ b/UnitsNet/GeneratedCode/Extensions/Number/NumberToLapseRateExtensions.g.cs @@ -0,0 +1,117 @@ +//------------------------------------------------------------------------------ +// +// 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.NumberToLapseRate +{ + public static class NumberToLapseRateExtensions + { + #region DegreeCelsiusPerMeter + + /// + public static LapseRate DegreesCelciusPerMeter(this int value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate? DegreesCelciusPerMeter(this int? value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate DegreesCelciusPerMeter(this long value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate? DegreesCelciusPerMeter(this long? value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate DegreesCelciusPerMeter(this double value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate? DegreesCelciusPerMeter(this double? value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate DegreesCelciusPerMeter(this float value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate? DegreesCelciusPerMeter(this float? value) => LapseRate.FromDegreesCelciusPerMeter(value); + + /// + public static LapseRate DegreesCelciusPerMeter(this decimal value) => LapseRate.FromDegreesCelciusPerMeter(Convert.ToDouble(value)); + + /// + public static LapseRate? DegreesCelciusPerMeter(this decimal? value) => LapseRate.FromDegreesCelciusPerMeter(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region KilodegreeCelsiusPerMeter + + /// + public static LapseRate KilodegreesCelciusPerMeter(this int value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate? KilodegreesCelciusPerMeter(this int? value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate KilodegreesCelciusPerMeter(this long value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate? KilodegreesCelciusPerMeter(this long? value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate KilodegreesCelciusPerMeter(this double value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate? KilodegreesCelciusPerMeter(this double? value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate KilodegreesCelciusPerMeter(this float value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate? KilodegreesCelciusPerMeter(this float? value) => LapseRate.FromKilodegreesCelciusPerMeter(value); + + /// + public static LapseRate KilodegreesCelciusPerMeter(this decimal value) => LapseRate.FromKilodegreesCelciusPerMeter(Convert.ToDouble(value)); + + /// + public static LapseRate? KilodegreesCelciusPerMeter(this decimal? value) => LapseRate.FromKilodegreesCelciusPerMeter(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + } +} +#endif diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs new file mode 100644 index 0000000000..5291f26dbd --- /dev/null +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -0,0 +1,832 @@ +//------------------------------------------------------------------------------ +// +// 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 +{ + /// + /// Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude. + /// + // 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 LapseRate +#else + public partial struct LapseRate : IComparable, IComparable +#endif + { + /// + /// Base unit of LapseRate. + /// + private readonly double _degreesCelciusPerMeter; + + // Windows Runtime Component requires a default constructor +#if WINDOWS_UWP + public LapseRate() : this(0) + { + } +#endif + + public LapseRate(double degreescelciuspermeter) + { + _degreesCelciusPerMeter = Convert.ToDouble(degreescelciuspermeter); + } + + // 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 + LapseRate(long degreescelciuspermeter) + { + _degreesCelciusPerMeter = Convert.ToDouble(degreescelciuspermeter); + } + + // 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 + LapseRate(decimal degreescelciuspermeter) + { + _degreesCelciusPerMeter = Convert.ToDouble(degreescelciuspermeter); + } + + #region Properties + + /// + /// The of this quantity. + /// + public static QuantityType QuantityType => QuantityType.LapseRate; + + /// + /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value. + /// + public static LapseRateUnit BaseUnit + { + get { return LapseRateUnit.DegreeCelsiusPerMeter; } + } + + /// + /// All units of measurement for the LapseRate quantity. + /// + public static LapseRateUnit[] Units { get; } = Enum.GetValues(typeof(LapseRateUnit)).Cast().ToArray(); + + /// + /// Get LapseRate in DegreesCelciusPerMeter. + /// + public double DegreesCelciusPerMeter + { + get { return _degreesCelciusPerMeter; } + } + + /// + /// Get LapseRate in KilodegreesCelciusPerMeter. + /// + public double KilodegreesCelciusPerMeter + { + get { return (_degreesCelciusPerMeter) / 1e3d; } + } + + #endregion + + #region Static + + public static LapseRate Zero + { + get { return new LapseRate(); } + } + + /// + /// Get LapseRate from DegreesCelciusPerMeter. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static LapseRate FromDegreesCelciusPerMeter(double degreescelciuspermeter) + { + return new LapseRate(degreescelciuspermeter); + } + + /// + /// Get LapseRate from DegreesCelciusPerMeter. + /// + public static LapseRate FromDegreesCelciusPerMeter(int degreescelciuspermeter) + { + return new LapseRate(degreescelciuspermeter); + } + + /// + /// Get LapseRate from DegreesCelciusPerMeter. + /// + public static LapseRate FromDegreesCelciusPerMeter(long degreescelciuspermeter) + { + return new LapseRate(degreescelciuspermeter); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get LapseRate from DegreesCelciusPerMeter of type decimal. + /// + public static LapseRate FromDegreesCelciusPerMeter(decimal degreescelciuspermeter) + { + return new LapseRate(Convert.ToDouble(degreescelciuspermeter)); + } +#endif + + /// + /// Get LapseRate from KilodegreesCelciusPerMeter. + /// +#if NETFX_CORE + [Windows.Foundation.Metadata.DefaultOverload] +#endif + public static LapseRate FromKilodegreesCelciusPerMeter(double kilodegreescelciuspermeter) + { + return new LapseRate((kilodegreescelciuspermeter) * 1e3d); + } + + /// + /// Get LapseRate from KilodegreesCelciusPerMeter. + /// + public static LapseRate FromKilodegreesCelciusPerMeter(int kilodegreescelciuspermeter) + { + return new LapseRate((kilodegreescelciuspermeter) * 1e3d); + } + + /// + /// Get LapseRate from KilodegreesCelciusPerMeter. + /// + public static LapseRate FromKilodegreesCelciusPerMeter(long kilodegreescelciuspermeter) + { + return new LapseRate((kilodegreescelciuspermeter) * 1e3d); + } + + // Windows Runtime Component does not support decimal type +#if !WINDOWS_UWP + /// + /// Get LapseRate from KilodegreesCelciusPerMeter of type decimal. + /// + public static LapseRate FromKilodegreesCelciusPerMeter(decimal kilodegreescelciuspermeter) + { + return new LapseRate((Convert.ToDouble(kilodegreescelciuspermeter)) * 1e3d); + } +#endif + + // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx +#if !WINDOWS_UWP + /// + /// Get nullable LapseRate from nullable DegreesCelciusPerMeter. + /// + public static LapseRate? FromDegreesCelciusPerMeter(double? degreescelciuspermeter) + { + if (degreescelciuspermeter.HasValue) + { + return FromDegreesCelciusPerMeter(degreescelciuspermeter.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable LapseRate from nullable DegreesCelciusPerMeter. + /// + public static LapseRate? FromDegreesCelciusPerMeter(int? degreescelciuspermeter) + { + if (degreescelciuspermeter.HasValue) + { + return FromDegreesCelciusPerMeter(degreescelciuspermeter.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable LapseRate from nullable DegreesCelciusPerMeter. + /// + public static LapseRate? FromDegreesCelciusPerMeter(long? degreescelciuspermeter) + { + if (degreescelciuspermeter.HasValue) + { + return FromDegreesCelciusPerMeter(degreescelciuspermeter.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable LapseRate from DegreesCelciusPerMeter of type decimal. + /// + public static LapseRate? FromDegreesCelciusPerMeter(decimal? degreescelciuspermeter) + { + if (degreescelciuspermeter.HasValue) + { + return FromDegreesCelciusPerMeter(degreescelciuspermeter.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable LapseRate from nullable KilodegreesCelciusPerMeter. + /// + public static LapseRate? FromKilodegreesCelciusPerMeter(double? kilodegreescelciuspermeter) + { + if (kilodegreescelciuspermeter.HasValue) + { + return FromKilodegreesCelciusPerMeter(kilodegreescelciuspermeter.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable LapseRate from nullable KilodegreesCelciusPerMeter. + /// + public static LapseRate? FromKilodegreesCelciusPerMeter(int? kilodegreescelciuspermeter) + { + if (kilodegreescelciuspermeter.HasValue) + { + return FromKilodegreesCelciusPerMeter(kilodegreescelciuspermeter.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable LapseRate from nullable KilodegreesCelciusPerMeter. + /// + public static LapseRate? FromKilodegreesCelciusPerMeter(long? kilodegreescelciuspermeter) + { + if (kilodegreescelciuspermeter.HasValue) + { + return FromKilodegreesCelciusPerMeter(kilodegreescelciuspermeter.Value); + } + else + { + return null; + } + } + + /// + /// Get nullable LapseRate from KilodegreesCelciusPerMeter of type decimal. + /// + public static LapseRate? FromKilodegreesCelciusPerMeter(decimal? kilodegreescelciuspermeter) + { + if (kilodegreescelciuspermeter.HasValue) + { + return FromKilodegreesCelciusPerMeter(kilodegreescelciuspermeter.Value); + } + else + { + return null; + } + } + +#endif + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// LapseRate unit value. + public static LapseRate From(double val, LapseRateUnit fromUnit) + { + switch (fromUnit) + { + case LapseRateUnit.DegreeCelsiusPerMeter: + return FromDegreesCelciusPerMeter(val); + case LapseRateUnit.KilodegreeCelsiusPerMeter: + return FromKilodegreesCelciusPerMeter(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. + /// LapseRate unit value. + public static LapseRate? From(double? value, LapseRateUnit fromUnit) + { + if (!value.HasValue) + { + return null; + } + switch (fromUnit) + { + case LapseRateUnit.DegreeCelsiusPerMeter: + return FromDegreesCelciusPerMeter(value.Value); + case LapseRateUnit.KilodegreeCelsiusPerMeter: + return FromKilodegreesCelciusPerMeter(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(LapseRateUnit 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(LapseRateUnit 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 LapseRate operator -(LapseRate right) + { + return new LapseRate(-right._degreesCelciusPerMeter); + } + + public static LapseRate operator +(LapseRate left, LapseRate right) + { + return new LapseRate(left._degreesCelciusPerMeter + right._degreesCelciusPerMeter); + } + + public static LapseRate operator -(LapseRate left, LapseRate right) + { + return new LapseRate(left._degreesCelciusPerMeter - right._degreesCelciusPerMeter); + } + + public static LapseRate operator *(double left, LapseRate right) + { + return new LapseRate(left*right._degreesCelciusPerMeter); + } + + public static LapseRate operator *(LapseRate left, double right) + { + return new LapseRate(left._degreesCelciusPerMeter*(double)right); + } + + public static LapseRate operator /(LapseRate left, double right) + { + return new LapseRate(left._degreesCelciusPerMeter/(double)right); + } + + public static double operator /(LapseRate left, LapseRate right) + { + return Convert.ToDouble(left._degreesCelciusPerMeter/right._degreesCelciusPerMeter); + } +#endif + + #endregion + + #region Equality / IComparable + + public int CompareTo(object obj) + { + if (obj == null) throw new ArgumentNullException("obj"); + if (!(obj is LapseRate)) throw new ArgumentException("Expected type LapseRate.", "obj"); + return CompareTo((LapseRate) 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(LapseRate other) + { + return _degreesCelciusPerMeter.CompareTo(other._degreesCelciusPerMeter); + } + + // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx +#if !WINDOWS_UWP + public static bool operator <=(LapseRate left, LapseRate right) + { + return left._degreesCelciusPerMeter <= right._degreesCelciusPerMeter; + } + + public static bool operator >=(LapseRate left, LapseRate right) + { + return left._degreesCelciusPerMeter >= right._degreesCelciusPerMeter; + } + + public static bool operator <(LapseRate left, LapseRate right) + { + return left._degreesCelciusPerMeter < right._degreesCelciusPerMeter; + } + + public static bool operator >(LapseRate left, LapseRate right) + { + return left._degreesCelciusPerMeter > right._degreesCelciusPerMeter; + } + + public static bool operator ==(LapseRate left, LapseRate right) + { + // ReSharper disable once CompareOfFloatsByEqualityOperator + return left._degreesCelciusPerMeter == right._degreesCelciusPerMeter; + } + + public static bool operator !=(LapseRate left, LapseRate right) + { + // ReSharper disable once CompareOfFloatsByEqualityOperator + return left._degreesCelciusPerMeter != right._degreesCelciusPerMeter; + } +#endif + + public override bool Equals(object obj) + { + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + + return _degreesCelciusPerMeter.Equals(((LapseRate) obj)._degreesCelciusPerMeter); + } + + public override int GetHashCode() + { + return _degreesCelciusPerMeter.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(LapseRateUnit unit) + { + switch (unit) + { + case LapseRateUnit.DegreeCelsiusPerMeter: + return DegreesCelciusPerMeter; + case LapseRateUnit.KilodegreeCelsiusPerMeter: + return KilodegreesCelciusPerMeter; + + 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 LapseRate Parse(string str) + { + return Parse(str, null); + } + + /// + /// Parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// 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 LapseRate 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); + LapseRateUnit parsedUnit = ParseUnit(unit, formatProvider2); + return From(parsedValue, parsedUnit); + }, (x, y) => FromDegreesCelciusPerMeter(x.DegreesCelciusPerMeter + y.DegreesCelciusPerMeter)); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// + /// Length.Parse("5.5 m", new CultureInfo("en-US")); + /// + public static bool TryParse([CanBeNull] string str, out LapseRate result) + { + return TryParse(str, null, out result); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// 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 LapseRate result) + { + try + { + result = Parse(str, culture); + return true; + } + catch + { + result = default(LapseRate); + 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 LapseRateUnit 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 LapseRateUnit 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 LapseRateUnit 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 == LapseRateUnit.Undefined) + { + var newEx = new UnitsNetException("Error parsing string. The unit is not a recognized LapseRateUnit."); + newEx.Data["input"] = str; + newEx.Data["formatprovider"] = formatProvider?.ToString() ?? "(null)"; + throw newEx; + } + + return unit; + } + + #endregion + + /// + /// Set the default unit used by ToString(). Default is DegreeCelsiusPerMeter + /// + public static LapseRateUnit ToStringDefaultUnit { get; set; } = LapseRateUnit.DegreeCelsiusPerMeter; + + /// + /// 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(LapseRateUnit 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(LapseRateUnit 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(LapseRateUnit 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(LapseRateUnit 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 LapseRate + /// + public static LapseRate MaxValue + { + get + { + return new LapseRate(double.MaxValue); + } + } + + /// + /// Represents the smallest possible value of LapseRate + /// + public static LapseRate MinValue + { + get + { + return new LapseRate(double.MinValue); + } + } + } +} diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index ff856ee082..214b34ffda 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -56,7 +56,7 @@ namespace UnitsNet { /// - /// + /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. /// // ReSharper disable once PartialTypeWithSinglePart diff --git a/UnitsNet/GeneratedCode/QuantityType.g.cs b/UnitsNet/GeneratedCode/QuantityType.g.cs index 9815bacd46..2ae3e27e0d 100644 --- a/UnitsNet/GeneratedCode/QuantityType.g.cs +++ b/UnitsNet/GeneratedCode/QuantityType.g.cs @@ -74,13 +74,14 @@ public enum QuantityType Frequency, Information, KinematicViscosity, + LapseRate, Length, Level, Mass, MassFlow, MassMomentOfInertia, - MolarEntropy, MolarEnergy, + MolarEntropy, Molarity, MolarMass, Power, diff --git a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs index 03dd521522..b5b0ba93fe 100644 --- a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs +++ b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs @@ -1476,6 +1476,20 @@ private static readonly ReadOnlyCollection DefaultLocalization new AbbreviationsForCulture("ru-RU", "Ст"), }), }), + new UnitLocalization(typeof (LapseRateUnit), + new[] + { + new CulturesForEnumValue((int) LapseRateUnit.DegreeCelsiusPerMeter, + new[] + { + new AbbreviationsForCulture("en-US", "°C/m"), + }), + new CulturesForEnumValue((int) LapseRateUnit.KilodegreeCelsiusPerMeter, + new[] + { + new AbbreviationsForCulture("en-US", "k°C/m"), + }), + }), new UnitLocalization(typeof (LengthUnit), new[] { @@ -1953,40 +1967,42 @@ private static readonly ReadOnlyCollection DefaultLocalization new AbbreviationsForCulture("en-US", "t·mm²"), }), }), - new UnitLocalization(typeof (MolarEntropyUnit), + new UnitLocalization(typeof (MolarEnergyUnit), new[] { - new CulturesForEnumValue((int) MolarEntropyUnit.JoulePerMoleKelvin, + new CulturesForEnumValue((int) MolarEnergyUnit.JoulePerMole, new[] { - new AbbreviationsForCulture("en-US", "J/(mol*K)"), + new AbbreviationsForCulture("en-US", "J/mol"), }), - new CulturesForEnumValue((int) MolarEntropyUnit.KilojoulePerMoleKelvin, + new CulturesForEnumValue((int) MolarEnergyUnit.KilojoulePerMole, new[] { - new AbbreviationsForCulture("en-US", "kJ/(mol*K)"), + new AbbreviationsForCulture("en-US", "kJ/mol"), }), - new CulturesForEnumValue((int) MolarEntropyUnit.MegajoulePerMoleKelvin, + new CulturesForEnumValue((int) MolarEnergyUnit.MegajoulePerMole, new[] { - new AbbreviationsForCulture("en-US", "MJ/(mol*K)"), - new UnitLocalization(typeof (MolarEnergyUnit), + new AbbreviationsForCulture("en-US", "MJ/mol"), + }), + }), + new UnitLocalization(typeof (MolarEntropyUnit), new[] { - new CulturesForEnumValue((int) MolarEnergyUnit.JoulePerMole, + new CulturesForEnumValue((int) MolarEntropyUnit.JoulePerMoleKelvin, new[] { - new AbbreviationsForCulture("en-US", "J/mol"), + new AbbreviationsForCulture("en-US", "J/(mol*K)"), }), - new CulturesForEnumValue((int) MolarEnergyUnit.KilojoulePerMole, + new CulturesForEnumValue((int) MolarEntropyUnit.KilojoulePerMoleKelvin, new[] { - new AbbreviationsForCulture("en-US", "kJ/mol"), + new AbbreviationsForCulture("en-US", "kJ/(mol*K)"), }), - new CulturesForEnumValue((int) MolarEnergyUnit.MegajoulePerMole, + new CulturesForEnumValue((int) MolarEntropyUnit.MegajoulePerMoleKelvin, new[] { - new AbbreviationsForCulture("en-US", "MJ/mol"), + new AbbreviationsForCulture("en-US", "MJ/(mol*K)"), }), }), new UnitLocalization(typeof (MolarityUnit), diff --git a/UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs new file mode 100644 index 0000000000..2be0409dba --- /dev/null +++ b/UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------ +// +// 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 LapseRateUnit + { + Undefined = 0, + DegreeCelsiusPerMeter, + KilodegreeCelsiusPerMeter, + } +} diff --git a/UnitsNet/UnitDefinitions/LapseRate.json b/UnitsNet/UnitDefinitions/LapseRate.json new file mode 100644 index 0000000000..08b43ffa87 --- /dev/null +++ b/UnitsNet/UnitDefinitions/LapseRate.json @@ -0,0 +1,20 @@ +{ + "Name": "LapseRate", + "BaseUnit": "DegreeCelsiusPerMeter", + "XmlDoc": "Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude.", + "Units": [ + { + "SingularName": "DegreeCelsiusPerMeter", + "PluralName": "DegreesCelciusPerMeter", + "FromUnitToBaseFunc": "x", + "FromBaseToUnitFunc": "x", + "Prefixes": [ "Kilo" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "°C/m" ] + } + ] + } + ] +} \ No newline at end of file