diff --git a/Common/GeneratedCode/Quantities/Force.Common.g.cs b/Common/GeneratedCode/Quantities/Force.Common.g.cs index 0f3f1abca3..e6b543bf20 100644 --- a/Common/GeneratedCode/Quantities/Force.Common.g.cs +++ b/Common/GeneratedCode/Quantities/Force.Common.g.cs @@ -191,11 +191,26 @@ public static BaseDimensions BaseDimensions /// public double Meganewtons => As(ForceUnit.Meganewton); + /// + /// Get Force in Micronewtons. + /// + public double Micronewtons => As(ForceUnit.Micronewton); + + /// + /// Get Force in Millinewtons. + /// + public double Millinewtons => As(ForceUnit.Millinewton); + /// /// Get Force in Newtons. /// public double Newtons => As(ForceUnit.Newton); + /// + /// Get Force in OunceForce. + /// + public double OunceForce => As(ForceUnit.OunceForce); + /// /// Get Force in Poundals. /// @@ -304,6 +319,34 @@ public static Force FromMeganewtons(QuantityValue meganewtons) return new Force(value, ForceUnit.Meganewton); } + /// + /// Get Force from Micronewtons. + /// +#if WINDOWS_UWP + [Windows.Foundation.Metadata.DefaultOverload] + public static Force FromMicronewtons(double micronewtons) +#else + public static Force FromMicronewtons(QuantityValue micronewtons) +#endif + { + double value = (double) micronewtons; + return new Force(value, ForceUnit.Micronewton); + } + + /// + /// Get Force from Millinewtons. + /// +#if WINDOWS_UWP + [Windows.Foundation.Metadata.DefaultOverload] + public static Force FromMillinewtons(double millinewtons) +#else + public static Force FromMillinewtons(QuantityValue millinewtons) +#endif + { + double value = (double) millinewtons; + return new Force(value, ForceUnit.Millinewton); + } + /// /// Get Force from Newtons. /// @@ -318,6 +361,20 @@ public static Force FromNewtons(QuantityValue newtons) return new Force(value, ForceUnit.Newton); } + /// + /// Get Force from OunceForce. + /// +#if WINDOWS_UWP + [Windows.Foundation.Metadata.DefaultOverload] + public static Force FromOunceForce(double ounceforce) +#else + public static Force FromOunceForce(QuantityValue ounceforce) +#endif + { + double value = (double) ounceforce; + return new Force(value, ForceUnit.OunceForce); + } + /// /// Get Force from Poundals. /// @@ -538,7 +595,10 @@ private double AsBaseUnit() case ForceUnit.Kilonewton: return (_value) * 1e3d; case ForceUnit.KiloPond: return _value*9.80665002864; case ForceUnit.Meganewton: return (_value) * 1e6d; + case ForceUnit.Micronewton: return (_value) * 1e-6d; + case ForceUnit.Millinewton: return (_value) * 1e-3d; case ForceUnit.Newton: return _value; + case ForceUnit.OunceForce: return _value*2.780138509537812e-1; case ForceUnit.Poundal: return _value*0.13825502798973041652092282466083; case ForceUnit.PoundForce: return _value*4.4482216152605095551842641431421; case ForceUnit.TonneForce: return _value*9.80665002864e3; @@ -562,7 +622,10 @@ private double AsBaseNumericType(ForceUnit unit) case ForceUnit.Kilonewton: return (baseUnitValue) / 1e3d; case ForceUnit.KiloPond: return baseUnitValue/9.80665002864; case ForceUnit.Meganewton: return (baseUnitValue) / 1e6d; + case ForceUnit.Micronewton: return (baseUnitValue) / 1e-6d; + case ForceUnit.Millinewton: return (baseUnitValue) / 1e-3d; case ForceUnit.Newton: return baseUnitValue; + case ForceUnit.OunceForce: return baseUnitValue/2.780138509537812e-1; case ForceUnit.Poundal: return baseUnitValue/0.13825502798973041652092282466083; case ForceUnit.PoundForce: return baseUnitValue/4.4482216152605095551842641431421; case ForceUnit.TonneForce: return baseUnitValue/9.80665002864e3; diff --git a/Common/UnitDefinitions/Force.json b/Common/UnitDefinitions/Force.json index f0886176d1..792461c8cb 100644 --- a/Common/UnitDefinitions/Force.json +++ b/Common/UnitDefinitions/Force.json @@ -61,7 +61,7 @@ "PluralName": "Newtons", "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", - "Prefixes": [ "Deca", "Kilo", "Mega" ], + "Prefixes": [ "Micro", "Milli", "Deca", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", @@ -121,6 +121,18 @@ "Abbreviations": [ "фунт-сила" ] } ] + }, + { + "SingularName": "OunceForce", + "PluralName": "OunceForce", + "FromUnitToBaseFunc": "x*2.780138509537812e-1", + "FromBaseToUnitFunc": "x/2.780138509537812e-1", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "ozf" ] + } + ] } ] } \ No newline at end of file diff --git a/UnitsNet.Tests/CustomCode/ForceTests.cs b/UnitsNet.Tests/CustomCode/ForceTests.cs index fb348634a8..1e157075fb 100644 --- a/UnitsNet.Tests/CustomCode/ForceTests.cs +++ b/UnitsNet.Tests/CustomCode/ForceTests.cs @@ -43,6 +43,12 @@ public class ForceTests : ForceTestsBase protected override double TonnesForceInOneNewton => 1.019716212977928e-4; + protected override double MillinewtonsInOneNewton => 1.0e3; + + protected override double MicronewtonsInOneNewton => 1.0e6; + + protected override double OunceForceInOneNewton => 3.596943089595368; + [Fact] public void ForceDividedByAreaEqualsPressure() { diff --git a/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs index 72f36a6078..ea45f8121a 100644 --- a/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs @@ -59,7 +59,10 @@ public abstract partial class ForceTestsBase protected abstract double KilonewtonsInOneNewton { get; } protected abstract double KiloPondsInOneNewton { get; } protected abstract double MeganewtonsInOneNewton { get; } + protected abstract double MicronewtonsInOneNewton { get; } + protected abstract double MillinewtonsInOneNewton { get; } protected abstract double NewtonsInOneNewton { get; } + protected abstract double OunceForceInOneNewton { get; } protected abstract double PoundalsInOneNewton { get; } protected abstract double PoundsForceInOneNewton { get; } protected abstract double TonnesForceInOneNewton { get; } @@ -71,7 +74,10 @@ public abstract partial class ForceTestsBase protected virtual double KilonewtonsTolerance { get { return 1e-5; } } protected virtual double KiloPondsTolerance { get { return 1e-5; } } protected virtual double MeganewtonsTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsTolerance { get { return 1e-5; } } protected virtual double NewtonsTolerance { get { return 1e-5; } } + protected virtual double OunceForceTolerance { get { return 1e-5; } } protected virtual double PoundalsTolerance { get { return 1e-5; } } protected virtual double PoundsForceTolerance { get { return 1e-5; } } protected virtual double TonnesForceTolerance { get { return 1e-5; } } @@ -87,7 +93,10 @@ public void NewtonToForceUnits() AssertEx.EqualTolerance(KilonewtonsInOneNewton, newton.Kilonewtons, KilonewtonsTolerance); AssertEx.EqualTolerance(KiloPondsInOneNewton, newton.KiloPonds, KiloPondsTolerance); AssertEx.EqualTolerance(MeganewtonsInOneNewton, newton.Meganewtons, MeganewtonsTolerance); + AssertEx.EqualTolerance(MicronewtonsInOneNewton, newton.Micronewtons, MicronewtonsTolerance); + AssertEx.EqualTolerance(MillinewtonsInOneNewton, newton.Millinewtons, MillinewtonsTolerance); AssertEx.EqualTolerance(NewtonsInOneNewton, newton.Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(OunceForceInOneNewton, newton.OunceForce, OunceForceTolerance); AssertEx.EqualTolerance(PoundalsInOneNewton, newton.Poundals, PoundalsTolerance); AssertEx.EqualTolerance(PoundsForceInOneNewton, newton.PoundsForce, PoundsForceTolerance); AssertEx.EqualTolerance(TonnesForceInOneNewton, newton.TonnesForce, TonnesForceTolerance); @@ -102,7 +111,10 @@ public void FromValueAndUnit() AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Kilonewton).Kilonewtons, KilonewtonsTolerance); AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.KiloPond).KiloPonds, KiloPondsTolerance); AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Meganewton).Meganewtons, MeganewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Micronewton).Micronewtons, MicronewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Millinewton).Millinewtons, MillinewtonsTolerance); AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Newton).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.OunceForce).OunceForce, OunceForceTolerance); AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Poundal).Poundals, PoundalsTolerance); AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.PoundForce).PoundsForce, PoundsForceTolerance); AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.TonneForce).TonnesForce, TonnesForceTolerance); @@ -118,7 +130,10 @@ public void As() AssertEx.EqualTolerance(KilonewtonsInOneNewton, newton.As(ForceUnit.Kilonewton), KilonewtonsTolerance); AssertEx.EqualTolerance(KiloPondsInOneNewton, newton.As(ForceUnit.KiloPond), KiloPondsTolerance); AssertEx.EqualTolerance(MeganewtonsInOneNewton, newton.As(ForceUnit.Meganewton), MeganewtonsTolerance); + AssertEx.EqualTolerance(MicronewtonsInOneNewton, newton.As(ForceUnit.Micronewton), MicronewtonsTolerance); + AssertEx.EqualTolerance(MillinewtonsInOneNewton, newton.As(ForceUnit.Millinewton), MillinewtonsTolerance); AssertEx.EqualTolerance(NewtonsInOneNewton, newton.As(ForceUnit.Newton), NewtonsTolerance); + AssertEx.EqualTolerance(OunceForceInOneNewton, newton.As(ForceUnit.OunceForce), OunceForceTolerance); AssertEx.EqualTolerance(PoundalsInOneNewton, newton.As(ForceUnit.Poundal), PoundalsTolerance); AssertEx.EqualTolerance(PoundsForceInOneNewton, newton.As(ForceUnit.PoundForce), PoundsForceTolerance); AssertEx.EqualTolerance(TonnesForceInOneNewton, newton.As(ForceUnit.TonneForce), TonnesForceTolerance); @@ -153,10 +168,22 @@ public void ToUnit() AssertEx.EqualTolerance(MeganewtonsInOneNewton, (double)meganewtonQuantity.Value, MeganewtonsTolerance); Assert.Equal(ForceUnit.Meganewton, meganewtonQuantity.Unit); + var micronewtonQuantity = newton.ToUnit(ForceUnit.Micronewton); + AssertEx.EqualTolerance(MicronewtonsInOneNewton, (double)micronewtonQuantity.Value, MicronewtonsTolerance); + Assert.Equal(ForceUnit.Micronewton, micronewtonQuantity.Unit); + + var millinewtonQuantity = newton.ToUnit(ForceUnit.Millinewton); + AssertEx.EqualTolerance(MillinewtonsInOneNewton, (double)millinewtonQuantity.Value, MillinewtonsTolerance); + Assert.Equal(ForceUnit.Millinewton, millinewtonQuantity.Unit); + var newtonQuantity = newton.ToUnit(ForceUnit.Newton); AssertEx.EqualTolerance(NewtonsInOneNewton, (double)newtonQuantity.Value, NewtonsTolerance); Assert.Equal(ForceUnit.Newton, newtonQuantity.Unit); + var ounceforceQuantity = newton.ToUnit(ForceUnit.OunceForce); + AssertEx.EqualTolerance(OunceForceInOneNewton, (double)ounceforceQuantity.Value, OunceForceTolerance); + Assert.Equal(ForceUnit.OunceForce, ounceforceQuantity.Unit); + var poundalQuantity = newton.ToUnit(ForceUnit.Poundal); AssertEx.EqualTolerance(PoundalsInOneNewton, (double)poundalQuantity.Value, PoundalsTolerance); Assert.Equal(ForceUnit.Poundal, poundalQuantity.Unit); @@ -180,7 +207,10 @@ public void ConversionRoundTrip() AssertEx.EqualTolerance(1, Force.FromKilonewtons(newton.Kilonewtons).Newtons, KilonewtonsTolerance); AssertEx.EqualTolerance(1, Force.FromKiloPonds(newton.KiloPonds).Newtons, KiloPondsTolerance); AssertEx.EqualTolerance(1, Force.FromMeganewtons(newton.Meganewtons).Newtons, MeganewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromMicronewtons(newton.Micronewtons).Newtons, MicronewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromMillinewtons(newton.Millinewtons).Newtons, MillinewtonsTolerance); AssertEx.EqualTolerance(1, Force.FromNewtons(newton.Newtons).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromOunceForce(newton.OunceForce).Newtons, OunceForceTolerance); AssertEx.EqualTolerance(1, Force.FromPoundals(newton.Poundals).Newtons, PoundalsTolerance); AssertEx.EqualTolerance(1, Force.FromPoundsForce(newton.PoundsForce).Newtons, PoundsForceTolerance); AssertEx.EqualTolerance(1, Force.FromTonnesForce(newton.TonnesForce).Newtons, TonnesForceTolerance); diff --git a/UnitsNet/GeneratedCode/Extensions/Number/NumberToForceExtensions.g.cs b/UnitsNet/GeneratedCode/Extensions/Number/NumberToForceExtensions.g.cs index da7ac9dba4..bbb2e5b140 100644 --- a/UnitsNet/GeneratedCode/Extensions/Number/NumberToForceExtensions.g.cs +++ b/UnitsNet/GeneratedCode/Extensions/Number/NumberToForceExtensions.g.cs @@ -110,6 +110,28 @@ public static class NumberToForceExtensions #endregion + #region Micronewton + + /// + public static Force Micronewtons(this T value) => Force.FromMicronewtons(Convert.ToDouble(value)); + + /// + [Obsolete("Nullable type support has been deprecated and will be removed in a future release.")] + public static Force? Micronewtons(this T? value) where T : struct => Force.FromMicronewtons(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + + #region Millinewton + + /// + public static Force Millinewtons(this T value) => Force.FromMillinewtons(Convert.ToDouble(value)); + + /// + [Obsolete("Nullable type support has been deprecated and will be removed in a future release.")] + public static Force? Millinewtons(this T? value) where T : struct => Force.FromMillinewtons(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + #region Newton /// @@ -121,6 +143,17 @@ public static class NumberToForceExtensions #endregion + #region OunceForce + + /// + public static Force OunceForce(this T value) => Force.FromOunceForce(Convert.ToDouble(value)); + + /// + [Obsolete("Nullable type support has been deprecated and will be removed in a future release.")] + public static Force? OunceForce(this T? value) where T : struct => Force.FromOunceForce(value == null ? (double?)null : Convert.ToDouble(value.Value)); + + #endregion + #region Poundal /// diff --git a/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs index 0c4f5a070b..795ae79c9a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs @@ -116,6 +116,24 @@ public partial struct Force : IComparable, IComparable return meganewtons.HasValue ? FromMeganewtons(meganewtons.Value) : default(Force?); } + /// + /// Get nullable Force from nullable Micronewtons. + /// + [Obsolete("Nullable type support is obsolete and will be removed in a future release.")] + public static Force? FromMicronewtons(QuantityValue? micronewtons) + { + return micronewtons.HasValue ? FromMicronewtons(micronewtons.Value) : default(Force?); + } + + /// + /// Get nullable Force from nullable Millinewtons. + /// + [Obsolete("Nullable type support is obsolete and will be removed in a future release.")] + public static Force? FromMillinewtons(QuantityValue? millinewtons) + { + return millinewtons.HasValue ? FromMillinewtons(millinewtons.Value) : default(Force?); + } + /// /// Get nullable Force from nullable Newtons. /// @@ -125,6 +143,15 @@ public partial struct Force : IComparable, IComparable return newtons.HasValue ? FromNewtons(newtons.Value) : default(Force?); } + /// + /// Get nullable Force from nullable OunceForce. + /// + [Obsolete("Nullable type support is obsolete and will be removed in a future release.")] + public static Force? FromOunceForce(QuantityValue? ounceforce) + { + return ounceforce.HasValue ? FromOunceForce(ounceforce.Value) : default(Force?); + } + /// /// Get nullable Force from nullable Poundals. /// diff --git a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs index ff638eec87..c75e6a3189 100644 --- a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs +++ b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs @@ -1526,7 +1526,7 @@ private static readonly ReadOnlyCollection DefaultLocalization new[] { new AbbreviationsForCulture("en-US", "daN"), - new AbbreviationsForCulture("ru-RU", "даН"), + new AbbreviationsForCulture("ru-RU", ""), }), new CulturesForEnumValue((int) ForceUnit.Dyn, new[] @@ -1544,7 +1544,7 @@ private static readonly ReadOnlyCollection DefaultLocalization new[] { new AbbreviationsForCulture("en-US", "kN"), - new AbbreviationsForCulture("ru-RU", "кН"), + new AbbreviationsForCulture("ru-RU", ""), }), new CulturesForEnumValue((int) ForceUnit.KiloPond, new[] @@ -1558,12 +1558,29 @@ private static readonly ReadOnlyCollection DefaultLocalization new AbbreviationsForCulture("en-US", "MN"), new AbbreviationsForCulture("ru-RU", ""), }), + new CulturesForEnumValue((int) ForceUnit.Micronewton, + new[] + { + new AbbreviationsForCulture("en-US", "µN"), + new AbbreviationsForCulture("ru-RU", "даН"), + }), + new CulturesForEnumValue((int) ForceUnit.Millinewton, + new[] + { + new AbbreviationsForCulture("en-US", "mN"), + new AbbreviationsForCulture("ru-RU", "кН"), + }), new CulturesForEnumValue((int) ForceUnit.Newton, new[] { new AbbreviationsForCulture("en-US", "N"), new AbbreviationsForCulture("ru-RU", "Н"), }), + new CulturesForEnumValue((int) ForceUnit.OunceForce, + new[] + { + new AbbreviationsForCulture("en-US", "ozf"), + }), new CulturesForEnumValue((int) ForceUnit.Poundal, new[] { diff --git a/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs b/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs index d8984dc616..d3d1d901f0 100644 --- a/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs @@ -51,7 +51,10 @@ public enum ForceUnit Kilonewton, KiloPond, Meganewton, + Micronewton, + Millinewton, Newton, + OunceForce, Poundal, PoundForce, TonneForce,