diff --git a/Common/UnitDefinitions/Acceleration.json b/Common/UnitDefinitions/Acceleration.json index 17962cc640..ed292ace3c 100644 --- a/Common/UnitDefinitions/Acceleration.json +++ b/Common/UnitDefinitions/Acceleration.json @@ -10,6 +10,10 @@ { "SingularName": "MeterPerSecondSquared", "PluralName": "MetersPerSecondSquared", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ], @@ -23,8 +27,12 @@ { "SingularName": "InchPerSecondSquared", "PluralName": "InchesPerSecondSquared", + "BaseUnits": { + "L": "Inch", + "T": "Second" + }, "FromUnitToBaseFunc": "x*0.0254", - "FromBaseToUnitFunc": "x/0.0254", + "FromBaseToUnitFunc": "x/0.0254", "Localization": [ { "Culture": "en-US", @@ -35,6 +43,10 @@ { "SingularName": "FootPerSecondSquared", "PluralName": "FeetPerSecondSquared", + "BaseUnits": { + "L": "Foot", + "T": "Second" + }, "FromUnitToBaseFunc": "x*0.304800", "FromBaseToUnitFunc": "x/0.304800", "Localization": [ @@ -47,6 +59,10 @@ { "SingularName": "KnotPerSecond", "PluralName": "KnotsPerSecond", + "BaseUnits": { + "L": "NauticalMile", + "T": "Second" + }, "FromUnitToBaseFunc": "x*0.5144444444444", "FromBaseToUnitFunc": "x/0.5144444444444", "Localization": [ @@ -59,6 +75,10 @@ { "SingularName": "KnotPerMinute", "PluralName": "KnotsPerMinute", + "BaseUnits": { + "L": "NauticalMile", + "T": "Minute" + }, "FromUnitToBaseFunc": "x*0.5144444444444/60", "FromBaseToUnitFunc": "x/0.5144444444444*60", "Localization": [ @@ -71,6 +91,10 @@ { "SingularName": "KnotPerHour", "PluralName": "KnotsPerHour", + "BaseUnits": { + "L": "NauticalMile", + "T": "Hour" + }, "FromUnitToBaseFunc": "x*0.5144444444444/3600", "FromBaseToUnitFunc": "x/0.5144444444444*3600", "Localization": [ @@ -83,6 +107,10 @@ { "SingularName": "StandardGravity", "PluralName": "StandardGravity", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "x*9.80665", "FromBaseToUnitFunc": "x/9.80665", "Localization": [ diff --git a/Common/UnitDefinitions/AmountOfSubstance.json b/Common/UnitDefinitions/AmountOfSubstance.json index 0f39d3d67b..101b13dcde 100644 --- a/Common/UnitDefinitions/AmountOfSubstance.json +++ b/Common/UnitDefinitions/AmountOfSubstance.json @@ -11,6 +11,9 @@ "PluralName": "Moles", "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", + "BaseUnits": { + "N": "Mole" + }, "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega"], "Localization": [ { @@ -22,6 +25,9 @@ { "SingularName": "PoundMole", "PluralName": "PoundMoles", + "BaseUnits": { + "N": "PoundMole" + }, "FromUnitToBaseFunc": "x*453.59237", "FromBaseToUnitFunc": "x/453.59237", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ], diff --git a/Common/UnitDefinitions/Area.json b/Common/UnitDefinitions/Area.json index 4d58e86f2d..8ea94c9ace 100644 --- a/Common/UnitDefinitions/Area.json +++ b/Common/UnitDefinitions/Area.json @@ -9,6 +9,9 @@ { "SingularName": "SquareKilometer", "PluralName": "SquareKilometers", + "BaseUnits": { + "L": "Kilometer" + }, "FromUnitToBaseFunc": "x*1e6", "FromBaseToUnitFunc": "x/1e6", "Localization": [ @@ -25,6 +28,9 @@ { "SingularName": "SquareMeter", "PluralName": "SquareMeters", + "BaseUnits": { + "L": "Meter" + }, "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", "Localization": [ @@ -41,6 +47,9 @@ { "SingularName": "SquareDecimeter", "PluralName": "SquareDecimeters", + "BaseUnits": { + "L": "Decimeter" + }, "FromUnitToBaseFunc": "x*1e-2", "FromBaseToUnitFunc": "x/1e-2", "Localization": [ @@ -57,6 +66,9 @@ { "SingularName": "SquareCentimeter", "PluralName": "SquareCentimeters", + "BaseUnits": { + "L": "Centimeter" + }, "FromUnitToBaseFunc": "x*1e-4", "FromBaseToUnitFunc": "x/1e-4", "Localization": [ @@ -73,6 +85,9 @@ { "SingularName": "SquareMillimeter", "PluralName": "SquareMillimeters", + "BaseUnits": { + "L": "Millimeter" + }, "FromUnitToBaseFunc": "x*1e-6", "FromBaseToUnitFunc": "x/1e-6", "Localization": [ @@ -89,6 +104,9 @@ { "SingularName": "SquareMicrometer", "PluralName": "SquareMicrometers", + "BaseUnits": { + "L": "Micrometer" + }, "FromUnitToBaseFunc": "x*1e-12", "FromBaseToUnitFunc": "x/1e-12", "Localization": [ @@ -105,6 +123,9 @@ { "SingularName": "SquareMile", "PluralName": "SquareMiles", + "BaseUnits": { + "L": "Mile" + }, "FromUnitToBaseFunc": "x*2.59e6", "FromBaseToUnitFunc": "x/2.59e6", "Localization": [ @@ -121,6 +142,9 @@ { "SingularName": "SquareYard", "PluralName": "SquareYards", + "BaseUnits": { + "L": "Yard" + }, "FromUnitToBaseFunc": "x*0.836127", "FromBaseToUnitFunc": "x/0.836127", "Localization": [ @@ -137,6 +161,9 @@ { "SingularName": "SquareFoot", "PluralName": "SquareFeet", + "BaseUnits": { + "L": "Foot" + }, "FromUnitToBaseFunc": "x*0.092903", "FromBaseToUnitFunc": "x/0.092903", "Localization": [ @@ -153,6 +180,9 @@ { "SingularName": "UsSurveySquareFoot", "PluralName": "UsSurveySquareFeet", + "BaseUnits": { + "L": "UsSurveyFoot" + }, "FromUnitToBaseFunc": "x*0.09290341161", "FromBaseToUnitFunc": "x/0.09290341161", "Localization": [ @@ -165,6 +195,9 @@ { "SingularName": "SquareInch", "PluralName": "SquareInches", + "BaseUnits": { + "L": "Inch" + }, "FromUnitToBaseFunc": "x*0.00064516", "FromBaseToUnitFunc": "x/0.00064516", "Localization": [ diff --git a/Common/UnitDefinitions/Duration.json b/Common/UnitDefinitions/Duration.json index 7343405e0e..061fc3b3a5 100644 --- a/Common/UnitDefinitions/Duration.json +++ b/Common/UnitDefinitions/Duration.json @@ -9,6 +9,9 @@ { "SingularName": "Year365", "PluralName": "Years365", + "BaseUnits": { + "T": "Year365" + }, "FromUnitToBaseFunc": "x*365*24*3600", "FromBaseToUnitFunc": "x/(365*24*3600)", "Localization": [ @@ -25,6 +28,9 @@ { "SingularName": "Month30", "PluralName": "Months30", + "BaseUnits": { + "T": "Month30" + }, "FromUnitToBaseFunc": "x*30*24*3600", "FromBaseToUnitFunc": "x/(30*24*3600)", "Localization": [ @@ -41,6 +47,9 @@ { "SingularName": "Week", "PluralName": "Weeks", + "BaseUnits": { + "T": "Week" + }, "FromUnitToBaseFunc": "x*7*24*3600", "FromBaseToUnitFunc": "x/(7*24*3600)", "Localization": [ @@ -57,6 +66,9 @@ { "SingularName": "Day", "PluralName": "Days", + "BaseUnits": { + "T": "Day" + }, "FromUnitToBaseFunc": "x*24*3600", "FromBaseToUnitFunc": "x/(24*3600)", "Localization": [ @@ -73,6 +85,9 @@ { "SingularName": "Hour", "PluralName": "Hours", + "BaseUnits": { + "T": "Hour" + }, "FromUnitToBaseFunc": "x*3600", "FromBaseToUnitFunc": "x/3600", "Localization": [ @@ -89,6 +104,9 @@ { "SingularName": "Minute", "PluralName": "Minutes", + "BaseUnits": { + "T": "Minute" + }, "FromUnitToBaseFunc": "x*60", "FromBaseToUnitFunc": "x/60", "Localization": [ @@ -105,6 +123,9 @@ { "SingularName": "Second", "PluralName": "Seconds", + "BaseUnits": { + "T": "Second" + }, "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", "Prefixes": [ "Nano", "Micro", "Milli" ], diff --git a/Common/UnitDefinitions/ElectricCurrent.json b/Common/UnitDefinitions/ElectricCurrent.json index 5ba342a74e..d3e9305926 100644 --- a/Common/UnitDefinitions/ElectricCurrent.json +++ b/Common/UnitDefinitions/ElectricCurrent.json @@ -11,6 +11,9 @@ "PluralName": "Amperes", "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", + "BaseUnits": { + "I": "Ampere" + }, "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Centi", "Kilo", "Mega" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Energy.json b/Common/UnitDefinitions/Energy.json index 18f2a85f37..e2b2c4038c 100644 --- a/Common/UnitDefinitions/Energy.json +++ b/Common/UnitDefinitions/Energy.json @@ -11,6 +11,11 @@ { "SingularName": "Joule", "PluralName": "Joules", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", "Prefixes": [ "Kilo", "Mega" ], diff --git a/Common/UnitDefinitions/Length.json b/Common/UnitDefinitions/Length.json index ea24e97c88..e4606a04c0 100644 --- a/Common/UnitDefinitions/Length.json +++ b/Common/UnitDefinitions/Length.json @@ -9,6 +9,9 @@ { "SingularName": "Meter", "PluralName": "Meters", + "BaseUnits": { + "L": "Meter" + }, "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ], @@ -27,6 +30,9 @@ { "SingularName": "Mile", "PluralName": "Miles", + "BaseUnits": { + "L": "Mile" + }, "FromUnitToBaseFunc": "x*1609.34", "FromBaseToUnitFunc": "x/1609.34", "Localization": [ @@ -43,6 +49,9 @@ { "SingularName": "Yard", "PluralName": "Yards", + "BaseUnits": { + "L": "Yard" + }, "FromUnitToBaseFunc": "x*0.9144", "FromBaseToUnitFunc": "x/0.9144", "Localization": [ @@ -59,6 +68,9 @@ { "SingularName": "Foot", "PluralName": "Feet", + "BaseUnits": { + "L": "Foot" + }, "FromUnitToBaseFunc": "x*0.3048", "FromBaseToUnitFunc": "x/0.3048", "Localization": [ @@ -75,6 +87,9 @@ { "SingularName": "UsSurveyFoot", "PluralName": "UsSurveyFeet", + "BaseUnits": { + "L": "UsSurveyFoot" + }, "FromUnitToBaseFunc": "x*1200/3937", "FromBaseToUnitFunc": "x*3937/1200", "Localization": [ @@ -87,6 +102,9 @@ { "SingularName": "Inch", "PluralName": "Inches", + "BaseUnits": { + "L": "Inch" + }, "FromUnitToBaseFunc": "x*2.54e-2", "FromBaseToUnitFunc": "x/2.54e-2", "Localization": [ @@ -103,6 +121,9 @@ { "SingularName": "Mil", "PluralName": "Mils", + "BaseUnits": { + "L": "Mil" + }, "FromUnitToBaseFunc": "x*2.54e-5", "FromBaseToUnitFunc": "x/2.54e-5", "Localization": [ @@ -119,6 +140,9 @@ { "SingularName": "NauticalMile", "PluralName": "NauticalMiles", + "BaseUnits": { + "L": "NauticalMile" + }, "FromUnitToBaseFunc": "x*1852", "FromBaseToUnitFunc": "x/1852", "Localization": [ @@ -135,6 +159,9 @@ { "SingularName": "Fathom", "PluralName": "Fathoms", + "BaseUnits": { + "L": "Fathom" + }, "FromUnitToBaseFunc": "x*1.8288", "FromBaseToUnitFunc": "x/1.8288", "Localization": [ @@ -147,6 +174,9 @@ { "SingularName": "Shackle", "PluralName": "Shackles", + "BaseUnits": { + "L": "Shackle" + }, "FromUnitToBaseFunc": "x*27.432", "FromBaseToUnitFunc": "x/27.432", "Localization": [ @@ -159,6 +189,9 @@ { "SingularName": "Microinch", "PluralName": "Microinches", + "BaseUnits": { + "L": "Microinch" + }, "FromUnitToBaseFunc": "x*2.54e-8", "FromBaseToUnitFunc": "x/2.54e-8", "Localization": [ @@ -175,6 +208,9 @@ { "SingularName": "PrinterPoint", "PluralName": "PrinterPoints", + "BaseUnits": { + "L": "PrinterPoint" + }, "FromUnitToBaseFunc": "(x/72.27)*2.54e-2", "FromBaseToUnitFunc": "(x/2.54e-2)*72.27", "Localization": [ @@ -187,6 +223,9 @@ { "SingularName": "DtpPoint", "PluralName": "DtpPoints", + "BaseUnits": { + "L": "DtpPoint" + }, "FromUnitToBaseFunc": "(x/72)*2.54e-2", "FromBaseToUnitFunc": "(x/2.54e-2)*72", "Localization": [ @@ -199,6 +238,9 @@ { "SingularName": "PrinterPica", "PluralName": "PrinterPicas", + "BaseUnits": { + "L": "PrinterPica" + }, "FromUnitToBaseFunc": "x/237.106301584", "FromBaseToUnitFunc": "x*237.106301584", "Localization": [ @@ -211,6 +253,9 @@ { "SingularName": "DtpPica", "PluralName": "DtpPicas", + "BaseUnits": { + "L": "DtpPica" + }, "FromUnitToBaseFunc": "x/236.220472441", "FromBaseToUnitFunc": "x*236.220472441", "Localization": [ @@ -223,6 +268,9 @@ { "SingularName": "Twip", "PluralName": "Twips", + "BaseUnits": { + "L": "Twip" + }, "FromUnitToBaseFunc": "x/56692.913385826", "FromBaseToUnitFunc": "x*56692.913385826", "Localization": [ diff --git a/Common/UnitDefinitions/LuminousIntensity.json b/Common/UnitDefinitions/LuminousIntensity.json index d71c4477e2..f32f634628 100644 --- a/Common/UnitDefinitions/LuminousIntensity.json +++ b/Common/UnitDefinitions/LuminousIntensity.json @@ -10,6 +10,9 @@ { "SingularName": "Candela", "PluralName": "Candela", + "BaseUnits": { + "J": "Candela" + }, "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", "Localization": [ diff --git a/Common/UnitDefinitions/Mass.json b/Common/UnitDefinitions/Mass.json index c82cac206c..d4bc3b546c 100644 --- a/Common/UnitDefinitions/Mass.json +++ b/Common/UnitDefinitions/Mass.json @@ -9,6 +9,9 @@ { "SingularName": "Gram", "PluralName": "Grams", + "BaseUnits": { + "M": "Gram" + }, "FromUnitToBaseFunc": "x/1e3", "FromBaseToUnitFunc": "x*1e3", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo" ], @@ -27,6 +30,9 @@ { "SingularName": "Tonne", "PluralName": "Tonnes", + "BaseUnits": { + "M": "Tonne" + }, "FromUnitToBaseFunc": "x*1e3", "FromBaseToUnitFunc": "x/1e3", "Prefixes": [ "Kilo", "Mega" ], @@ -45,6 +51,9 @@ { "SingularName": "ShortTon", "PluralName": "ShortTons", + "BaseUnits": { + "M": "ShortTon" + }, "FromUnitToBaseFunc": "x*9.0718474e2", "FromBaseToUnitFunc": "x/9.0718474e2", "XmlDocSummary": "The short ton is a unit of mass equal to 2,000 pounds (907.18474 kg), that is most commonly used in the United States – known there simply as the ton.", @@ -63,6 +72,9 @@ { "SingularName": "LongTon", "PluralName": "LongTons", + "BaseUnits": { + "M": "LongTon" + }, "FromUnitToBaseFunc": "x*1.0160469088e3", "FromBaseToUnitFunc": "x/1.0160469088e3", "XmlDocSummary": "Long ton (weight ton or Imperial ton) is a unit of mass equal to 2,240 pounds (1,016 kg) and is the name for the unit called the \"ton\" in the avoirdupois or Imperial system of measurements that was used in the United Kingdom and several other Commonwealth countries before metrication.", @@ -81,6 +93,9 @@ { "SingularName": "Pound", "PluralName": "Pounds", + "BaseUnits": { + "M": "Pound" + }, "FromUnitToBaseFunc": "x*0.45359237", "FromBaseToUnitFunc": "x/0.45359237", "XmlDocSummary": "The pound or pound-mass (abbreviations: lb, lbm) is a unit of mass used in the imperial, United States customary and other systems of measurement. A number of different definitions have been used, the most common today being the international avoirdupois pound which is legally defined as exactly 0.45359237 kilograms, and which is divided into 16 avoirdupois ounces.", @@ -99,6 +114,9 @@ { "SingularName": "Ounce", "PluralName": "Ounces", + "BaseUnits": { + "M": "Ounce" + }, "FromUnitToBaseFunc": "x/35.2739619", "FromBaseToUnitFunc": "x*35.2739619", "XmlDocSummary": "An ounce (abbreviated oz) is usually the international avoirdupois ounce as used in the United States customary and British imperial systems, which is equal to one-sixteenth of a pound or approximately 28 grams. The abbreviation 'oz' derives from the Italian word onza (now spelled oncia).", @@ -113,6 +131,9 @@ { "SingularName": "Slug", "PluralName": "Slugs", + "BaseUnits": { + "M": "Slug" + }, "FromUnitToBaseFunc": "x/6.852176556196105e-2", "FromBaseToUnitFunc": "x*6.852176556196105e-2", "XmlDocSummary": "The slug (abbreviation slug) is a unit of mass that is accelerated by 1 ft/s² when a force of one pound (lbf) is exerted on it.", @@ -127,6 +148,9 @@ { "SingularName": "Stone", "PluralName": "Stone", + "BaseUnits": { + "M": "Stone" + }, "FromUnitToBaseFunc": "x/0.1574731728702698", "FromBaseToUnitFunc": "x*0.1574731728702698", "XmlDocSummary": "The stone (abbreviation st) is a unit of mass equal to 14 pounds avoirdupois (about 6.35 kilograms) used in Great Britain and Ireland for measuring human body weight.", @@ -141,6 +165,9 @@ { "SingularName": "ShortHundredweight", "PluralName": "ShortHundredweight", + "BaseUnits": { + "M": "ShortHundredweight" + }, "FromUnitToBaseFunc": "x/0.022046226218487758", "FromBaseToUnitFunc": "x*0.022046226218487758", "XmlDocSummary": "The short hundredweight (abbreviation cwt) is a unit of mass equal to 100 pounds in US and Canada. In British English, the short hundredweight is referred to as the \"cental\".", @@ -155,6 +182,9 @@ { "SingularName": "LongHundredweight", "PluralName": "LongHundredweight", + "BaseUnits": { + "M": "LongHundredweight" + }, "FromUnitToBaseFunc": "x/0.01968413055222121", "FromBaseToUnitFunc": "x*0.01968413055222121", "XmlDocSummary": "The long or imperial hundredweight (abbreviation cwt) is a unit of mass equal to 112 pounds in US and Canada.", @@ -169,6 +199,9 @@ { "SingularName": "Grain", "PluralName": "Grains", + "BaseUnits": { + "M": "Grain" + }, "FromUnitToBaseFunc": "x/15432.358352941431", "FromBaseToUnitFunc": "x*15432.358352941431", "XmlDocSummary": "A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams.", diff --git a/Common/UnitDefinitions/Temperature.json b/Common/UnitDefinitions/Temperature.json index 4bbf2a513e..a9d838237f 100644 --- a/Common/UnitDefinitions/Temperature.json +++ b/Common/UnitDefinitions/Temperature.json @@ -10,6 +10,9 @@ { "SingularName": "Kelvin", "PluralName": "Kelvins", + "BaseUnits": { + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "x", "FromBaseToUnitFunc": "x", "Localization": [ @@ -22,6 +25,9 @@ { "SingularName": "DegreeCelsius", "PluralName": "DegreesCelsius", + "BaseUnits": { + "Θ": "DegreeCelsius" + }, "FromUnitToBaseFunc": "x + 273.15", "FromBaseToUnitFunc": "x - 273.15", "Localization": [ @@ -34,6 +40,9 @@ { "SingularName": "DegreeDelisle", "PluralName": "DegreesDelisle", + "BaseUnits": { + "Θ": "DegreeDelisle" + }, "FromUnitToBaseFunc": "x*-2/3 + 373.15", "FromBaseToUnitFunc": "(x - 373.15)*-3/2", "Localization": [ @@ -46,6 +55,9 @@ { "SingularName": "DegreeFahrenheit", "PluralName": "DegreesFahrenheit", + "BaseUnits": { + "Θ": "DegreeFahrenheit" + }, "FromUnitToBaseFunc": "x*5/9 + 459.67*5/9", "FromBaseToUnitFunc": "(x - 459.67*5/9)*9/5", "Localization": [ @@ -58,6 +70,9 @@ { "SingularName": "DegreeNewton", "PluralName": "DegreesNewton", + "BaseUnits": { + "Θ": "DegreeNewton" + }, "FromUnitToBaseFunc": "x*100/33 + 273.15", "FromBaseToUnitFunc": "(x - 273.15)*33/100", "Localization": [ @@ -70,6 +85,9 @@ { "SingularName": "DegreeRankine", "PluralName": "DegreesRankine", + "BaseUnits": { + "Θ": "DegreeRankine" + }, "FromUnitToBaseFunc": "x*5/9", "FromBaseToUnitFunc": "x*9/5", "Localization": [ @@ -82,6 +100,9 @@ { "SingularName": "DegreeReaumur", "PluralName": "DegreesReaumur", + "BaseUnits": { + "Θ": "DegreeReaumur" + }, "FromUnitToBaseFunc": "x*5/4 + 273.15", "FromBaseToUnitFunc": "(x - 273.15)*4/5", "Localization": [ @@ -94,6 +115,9 @@ { "SingularName": "DegreeRoemer", "PluralName": "DegreesRoemer", + "BaseUnits": { + "Θ": "DegreeRoemer" + }, "FromUnitToBaseFunc": "x*40/21 + 273.15 - 7.5*40d/21", "FromBaseToUnitFunc": "(x - (273.15 - 7.5*40d/21))*21/40", "Localization": [ diff --git a/UnitsNet.Tests/BaseUnitsTests.cs b/UnitsNet.Tests/BaseUnitsTests.cs index 07e61f7421..698418b95c 100644 --- a/UnitsNet.Tests/BaseUnitsTests.cs +++ b/UnitsNet.Tests/BaseUnitsTests.cs @@ -91,6 +91,43 @@ public void InequalityOperatorIsImplementedCorrectly() Assert.False(nullBaseUnits1 != nullBaseUnits2); } + [Fact] + public void UndefinedHasAllBaseUnitsAsUndefined() + { + Assert.Equal(LengthUnit.Undefined, BaseUnits.Undefined.Length); + Assert.Equal(MassUnit.Undefined, BaseUnits.Undefined.Mass); + Assert.Equal(DurationUnit.Undefined, BaseUnits.Undefined.Time); + Assert.Equal(ElectricCurrentUnit.Undefined, BaseUnits.Undefined.Current); + Assert.Equal(TemperatureUnit.Undefined, BaseUnits.Undefined.Temperature); + Assert.Equal(AmountOfSubstanceUnit.Undefined, BaseUnits.Undefined.Amount); + Assert.Equal(LuminousIntensityUnit.Undefined, BaseUnits.Undefined.LuminousIntensity); + } + + [Fact] + public void UndefinedIsSubsetOfUndefined() + { + Assert.True(BaseUnits.Undefined.IsSubsetOf(BaseUnits.Undefined)); + } + + [Fact] + public void IsSubsetOfReturnsFalseWithNull() + { + Assert.False(siBaseUnits.IsSubsetOf(null)); + } + + [Fact] + public void ExistsInWorksCorrectly() + { + Assert.False(BaseUnits.Undefined.IsSubsetOf(siBaseUnits)); + Assert.False(siBaseUnits.IsSubsetOf(BaseUnits.Undefined)); + + var meterBaseUnits = new BaseUnits(LengthUnit.Meter); + Assert.True(meterBaseUnits.IsSubsetOf(siBaseUnits)); + + // Not all units in siBaseUnits will exist in meterBaseUnits + Assert.False(siBaseUnits.IsSubsetOf(meterBaseUnits)); + } + [Fact] public void ToStringGivesExpectedResult() { diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index 8ad55749b4..b3db19ebca 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -1,6 +1,7 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using UnitsNet.Units; using Xunit; namespace UnitsNet.Tests.CustomCode @@ -82,5 +83,12 @@ public void AreaTimesSpeedEqualsVolumeFlow() VolumeFlow volumeFlow = Area.FromSquareMeters(20) * Speed.FromMetersPerSecond(2); Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(40), volumeFlow); } + + [Fact] + public void Constructor_UnitSystemSI_AssignsSIUnit() + { + var area = new Area(1.0, UnitSystem.SI); + Assert.Equal(AreaUnit.SquareMeter, area.Unit); + } } } diff --git a/UnitsNet.Tests/CustomCode/EnergyTests.cs b/UnitsNet.Tests/CustomCode/EnergyTests.cs index 0c4c250926..8a8a420437 100644 --- a/UnitsNet.Tests/CustomCode/EnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/EnergyTests.cs @@ -1,6 +1,9 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using UnitsNet.Units; +using Xunit; + namespace UnitsNet.Tests.CustomCode { public class EnergyTests : EnergyTestsBase @@ -50,5 +53,12 @@ public class EnergyTests : EnergyTestsBase protected override double ThermsUsInOneJoule => 9.4804342797334860315281322406817e-9; protected override double WattHoursInOneJoule => 0.000277777778; + + [Fact] + public void Constructor_UnitSystemSI_AssignsSIUnit() + { + var energy = new Energy(1.0, UnitSystem.SI); + Assert.Equal(EnergyUnit.Joule, energy.Unit); + } } } diff --git a/UnitsNet.Tests/CustomCode/LengthTests.cs b/UnitsNet.Tests/CustomCode/LengthTests.cs index f3b8803640..0634c931f4 100644 --- a/UnitsNet.Tests/CustomCode/LengthTests.cs +++ b/UnitsNet.Tests/CustomCode/LengthTests.cs @@ -3,6 +3,7 @@ using Xunit; using UnitsNet.Units; +using System; namespace UnitsNet.Tests.CustomCode { @@ -151,5 +152,18 @@ public void NegativeLengthToStonePoundsReturnsCorrectValues() Assert.Equal(-2.0, feetInches.Feet); Assert.Equal(-1.0, feetInches.Inches); } + + [Fact] + public void Constructor_UnitSystemNull_ThrowsArgumentNullException() + { + Assert.Throws(() => new Length(1.0, (UnitSystem)null)); + } + + [Fact] + public void Constructor_UnitSystemSI_AssignsSIUnit() + { + var length = new Length(1.0, UnitSystem.SI); + Assert.Equal(LengthUnit.Meter, length.Unit); + } } } diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs index e9075f6303..f169fbcb9d 100644 --- a/UnitsNet.Tests/QuantityInfoTest.cs +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -15,107 +15,152 @@ public class QuantityInfoTest public void Constructor_AssignsProperties() { var expectedZero = Length.FromCentimeters(10); - var expectedUnits = new Enum[] {LengthUnit.Centimeter, LengthUnit.Kilometer}; - var expectedBaseUnit = LengthUnit.Meter; + var expectedUnitInfos = new UnitInfo[]{ + new UnitInfo(LengthUnit.Centimeter, new BaseUnits(LengthUnit.Centimeter)), + new UnitInfo(LengthUnit.Kilometer, new BaseUnits(LengthUnit.Kilometer)) + }; + var expectedBaseUnit = LengthUnit.Centimeter; var expectedQuantityType = QuantityType.Length; var expectedBaseDimensions = Length.BaseDimensions; - var info = new QuantityInfo(expectedQuantityType, expectedUnits, expectedBaseUnit, expectedZero, expectedBaseDimensions); + var info = new QuantityInfo(expectedQuantityType, expectedUnitInfos, + expectedBaseUnit, expectedZero, expectedBaseDimensions); Assert.Equal(expectedZero, info.Zero); Assert.Equal("Length", info.Name); + Assert.Equal(expectedUnitInfos, info.UnitInfos); + Assert.Equal(expectedQuantityType, info.QuantityType); + Assert.Equal(expectedBaseDimensions, info.BaseDimensions); + // Obsolete members #pragma warning disable 618 - Assert.Equal(expectedUnits, info.Units); - Assert.Equal(expectedBaseUnit, info.BaseUnit); - Assert.Equal(new[]{"Centimeter", "Kilometer"}, info.UnitNames); + Assert.Equal( expectedBaseUnit, info.BaseUnit ); + Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); #pragma warning restore 618 - Assert.Equal(expectedQuantityType, info.QuantityType); - Assert.Equal(expectedBaseDimensions, info.BaseDimensions); } [Fact] public void GenericsConstructor_AssignsProperties() { var expectedZero = Length.FromCentimeters(10); - var expectedUnits = new[] {LengthUnit.Centimeter, LengthUnit.Kilometer}; - var expectedBaseUnit = LengthUnit.Meter; + var expectedUnitInfos = new UnitInfo[]{ + new UnitInfo(LengthUnit.Centimeter, new BaseUnits(LengthUnit.Centimeter)), + new UnitInfo(LengthUnit.Kilometer, new BaseUnits(LengthUnit.Kilometer)) + }; + var expectedBaseUnit = LengthUnit.Centimeter; var expectedQuantityType = QuantityType.Length; var expectedBaseDimensions = Length.BaseDimensions; - var info = new QuantityInfo(expectedQuantityType, expectedUnits, expectedBaseUnit, expectedZero, expectedBaseDimensions); + var info = new QuantityInfo(expectedQuantityType, expectedUnitInfos, + expectedBaseUnit, expectedZero, expectedBaseDimensions); Assert.Equal(expectedZero, info.Zero); Assert.Equal("Length", info.Name); + Assert.Equal(expectedUnitInfos, info.UnitInfos); + Assert.Equal(expectedQuantityType, info.QuantityType); + Assert.Equal(expectedBaseDimensions, info.BaseDimensions); + // Obsolete members #pragma warning disable 618 - Assert.Equal(expectedUnits, info.Units); - Assert.Equal(expectedBaseUnit, info.BaseUnit); - Assert.Equal(new[]{"Centimeter", "Kilometer"}, info.UnitNames); + Assert.Equal( expectedBaseUnit, info.BaseUnit ); + Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); #pragma warning restore 618 - Assert.Equal(expectedQuantityType, info.QuantityType); - Assert.Equal(expectedBaseDimensions, info.BaseDimensions); } [Fact] public void Constructor_GivenUndefinedAsQuantityType_ThrowsArgumentException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Undefined, new Enum[0], Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Undefined, + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] public void GenericsConstructor_GivenUndefinedAsQuantityType_ThrowsArgumentException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Undefined, Length.Units, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Undefined, + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - public void Constructor_GivenNullAsUnits_ThrowsArgumentNullException() + public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - public void GenericsConstructor_GivenNullAsUnits_ThrowsArgumentNullException() + public void GenericsConstructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, new Enum[0], null, Length.Zero, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + Length.Info.UnitInfos, null, Length.Zero, Length.BaseDimensions)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, new Enum[0], Length.BaseUnit, null, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, Length.Units, Length.BaseUnit, null, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, new Enum[0], Length.BaseUnit, Length.Zero, null)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void GenericsConstructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, Length.Units, Length.BaseUnit, Length.Zero, null)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); + } + + [Fact] + public void GetUnitInfoFor_GivenNullAsBaseUnits_ThrowsArgumentNullException() + { + Assert.Throws(() => Length.Info.GetUnitInfoFor(null)); + } + + [Fact] + public void GetUnitInfoFor_GivenBaseUnitsWithNoMatch_ThrowsInvalidOperationException() + { + var baseUnitsWithNoMatch = new BaseUnits(mass: MassUnit.Kilogram); + Assert.Throws(() => Length.Info.GetUnitInfoFor(baseUnitsWithNoMatch)); + } + + [Fact] + public void GetUnitInfoFor_GivenBaseUnitsWithMultipleMatches_ThrowsInvalidOperationException() + { + var baseUnits = new BaseUnits(LengthUnit.Meter); + + var quantityInfo = new QuantityInfo(QuantityType.Length, new UnitInfo[]{ + new UnitInfo(LengthUnit.Meter, baseUnits), + new UnitInfo(LengthUnit.Foot, baseUnits) + }, LengthUnit.Meter, Length.Zero, Length.BaseDimensions); + + Assert.Throws(() => quantityInfo.GetUnitInfoFor(baseUnits)); } } } diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 05017e7262..fa7c7ac9cd 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -1,4 +1,4 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; diff --git a/UnitsNet.Tests/QuantityTests.Ctor.cs b/UnitsNet.Tests/QuantityTests.Ctor.cs index 29892d21e4..cd06c4e993 100644 --- a/UnitsNet.Tests/QuantityTests.Ctor.cs +++ b/UnitsNet.Tests/QuantityTests.Ctor.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using UnitsNet.Units; using Xunit; @@ -103,6 +104,12 @@ public void CtorWithValueAndUnitOfRepresentativeTypes_SetsValueAndUnit() Assert.Equal(5, level.Value); Assert.Equal(LevelUnit.Neper, level.Unit); } + + [Fact] + public void Constructor_UnitSystemGivenNull_ThrowsArgumentNullException() + { + Assert.Throws(() => new Length(1.0, null)); + } } } } diff --git a/UnitsNet.Tests/QuantityTests.cs b/UnitsNet.Tests/QuantityTests.cs index a3f341bee0..ab97ec0b6e 100644 --- a/UnitsNet.Tests/QuantityTests.cs +++ b/UnitsNet.Tests/QuantityTests.cs @@ -12,10 +12,10 @@ public partial class QuantityTests [Fact] public void GetHashCodeForDifferentQuantitiesWithSameValuesAreNotEqual() { - var length = new Length( 1.0, (LengthUnit)2 ); - var area = new Area( 1.0, (AreaUnit)2 ); + var length = new Length(1.0, (LengthUnit)2); + var area = new Area(1.0, (AreaUnit)2); - Assert.NotEqual( length.GetHashCode(), area.GetHashCode() ); + Assert.NotEqual(length.GetHashCode(), area.GetHashCode()); } [Fact] diff --git a/UnitsNet.Tests/UnitInfoTests.cs b/UnitsNet.Tests/UnitInfoTests.cs index 4b5d640d50..852b9042eb 100644 --- a/UnitsNet.Tests/UnitInfoTests.cs +++ b/UnitsNet.Tests/UnitInfoTests.cs @@ -11,7 +11,7 @@ public class UnitInfoTests [Fact] public void ConstructorTest() { - var unitInfo = new UnitInfo(LengthUnit.Meter); + var unitInfo = new UnitInfo(LengthUnit.Meter, new BaseUnits(LengthUnit.Meter)); Assert.Equal(LengthUnit.Meter, unitInfo.Value); Assert.Equal(LengthUnit.Meter.ToString(), unitInfo.Name); } @@ -19,7 +19,7 @@ public void ConstructorTest() [Fact] public void GenericConstructorTest() { - var unitInfo = new UnitInfo(LengthUnit.Meter); + var unitInfo = new UnitInfo(LengthUnit.Meter, new BaseUnits(LengthUnit.Meter)); Assert.Equal(LengthUnit.Meter, unitInfo.Value); Assert.Equal(LengthUnit.Meter.ToString(), unitInfo.Name); } diff --git a/UnitsNet.Tests/UnitParserTests.cs b/UnitsNet.Tests/UnitParserTests.cs index 8028e8b302..bd36e98e82 100644 --- a/UnitsNet.Tests/UnitParserTests.cs +++ b/UnitsNet.Tests/UnitParserTests.cs @@ -6,7 +6,7 @@ namespace UnitsNet.Tests { - [Collection( nameof( UnitAbbreviationsCacheFixture ) )] + [Collection(nameof(UnitAbbreviationsCacheFixture))] public class UnitParserTests { [Theory] diff --git a/UnitsNet/BaseUnits.cs b/UnitsNet/BaseUnits.cs index 01db20e5f2..0148b48b30 100644 --- a/UnitsNet/BaseUnits.cs +++ b/UnitsNet/BaseUnits.cs @@ -14,6 +14,11 @@ namespace UnitsNet /// public sealed class BaseUnits: IEquatable { + /// + /// Represents BaseUnits that have not been defined. + /// + public static BaseUnits Undefined { get; } = new BaseUnits(); + /// /// Creates an instance of if the base units class that represents the base units for a quantity. /// All quantities, both base and derived, can be represented by a combination of these seven base units. @@ -25,8 +30,14 @@ public sealed class BaseUnits: IEquatable /// The temperature unit (Θ). /// The amount of substance unit (N). /// The luminous intensity unit (J). - public BaseUnits(LengthUnit length, MassUnit mass, DurationUnit time, ElectricCurrentUnit current, - TemperatureUnit temperature, AmountOfSubstanceUnit amount, LuminousIntensityUnit luminousIntensity) + public BaseUnits( + LengthUnit length = LengthUnit.Undefined, + MassUnit mass = MassUnit.Undefined, + DurationUnit time = DurationUnit.Undefined, + ElectricCurrentUnit current = ElectricCurrentUnit.Undefined, + TemperatureUnit temperature = TemperatureUnit.Undefined, + AmountOfSubstanceUnit amount = AmountOfSubstanceUnit.Undefined, + LuminousIntensityUnit luminousIntensity = LuminousIntensityUnit.Undefined) { Length = length; Mass = mass; @@ -65,6 +76,31 @@ public bool Equals(BaseUnits other) LuminousIntensity == other.LuminousIntensity; } + /// + /// Checks if the base units are a subset of another. Undefined base units are ignored. + /// If all base united are undefined (equal to ), + /// IsSubsetOf will return true only if other is also equal to . + /// + /// The other to compare to. + /// True if the base units are a subset of other, otherwise false. + public bool IsSubsetOf(BaseUnits other) + { + if(other is null) + return false; + + // If all base units are undefined, can only be a subset of another where all base units are undefined. + if(Equals(Undefined)) + return other.Equals(Undefined); + + return (Length == LengthUnit.Undefined || Length == other.Length) && + (Mass == MassUnit.Undefined || Mass == other.Mass) && + (Time == DurationUnit.Undefined || Time == other.Time) && + (Current == ElectricCurrentUnit.Undefined || Current == other.Current) && + (Temperature == TemperatureUnit.Undefined || Temperature == other.Temperature) && + (Amount == AmountOfSubstanceUnit.Undefined || Amount == other.Amount) && + (LuminousIntensity == LuminousIntensityUnit.Undefined || LuminousIntensity == other.LuminousIntensity); + } + /// public override int GetHashCode() { diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs index 2b3c13ec87..443846e607 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs @@ -47,7 +47,24 @@ public partial struct Acceleration : IQuantity, IEquatable(QuantityType.Acceleration, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Acceleration, + new UnitInfo[] { + new UnitInfo(AccelerationUnit.CentimeterPerSecondSquared, BaseUnits.Undefined), + new UnitInfo(AccelerationUnit.DecimeterPerSecondSquared, BaseUnits.Undefined), + new UnitInfo(AccelerationUnit.FootPerSecondSquared, new BaseUnits(length: LengthUnit.Foot, time: DurationUnit.Second)), + new UnitInfo(AccelerationUnit.InchPerSecondSquared, new BaseUnits(length: LengthUnit.Inch, time: DurationUnit.Second)), + new UnitInfo(AccelerationUnit.KilometerPerSecondSquared, BaseUnits.Undefined), + new UnitInfo(AccelerationUnit.KnotPerHour, new BaseUnits(length: LengthUnit.NauticalMile, time: DurationUnit.Hour)), + new UnitInfo(AccelerationUnit.KnotPerMinute, new BaseUnits(length: LengthUnit.NauticalMile, time: DurationUnit.Minute)), + new UnitInfo(AccelerationUnit.KnotPerSecond, new BaseUnits(length: LengthUnit.NauticalMile, time: DurationUnit.Second)), + new UnitInfo(AccelerationUnit.MeterPerSecondSquared, new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)), + new UnitInfo(AccelerationUnit.MicrometerPerSecondSquared, BaseUnits.Undefined), + new UnitInfo(AccelerationUnit.MillimeterPerSecondSquared, BaseUnits.Undefined), + new UnitInfo(AccelerationUnit.NanometerPerSecondSquared, BaseUnits.Undefined), + new UnitInfo(AccelerationUnit.StandardGravity, new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +82,22 @@ public Acceleration(double numericValue, AccelerationUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Acceleration(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs index f75e9b2a96..3be81ab1b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs @@ -47,7 +47,26 @@ public partial struct AmountOfSubstance : IQuantity, IEqu static AmountOfSubstance() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0); - Info = new QuantityInfo(QuantityType.AmountOfSubstance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.AmountOfSubstance, + new UnitInfo[] { + new UnitInfo(AmountOfSubstanceUnit.Centimole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.CentipoundMole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.Decimole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.DecipoundMole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.Kilomole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.KilopoundMole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.Megamole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.Micromole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.MicropoundMole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.Millimole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.MillipoundMole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.Mole, new BaseUnits(amount: AmountOfSubstanceUnit.Mole)), + new UnitInfo(AmountOfSubstanceUnit.Nanomole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.NanopoundMole, BaseUnits.Undefined), + new UnitInfo(AmountOfSubstanceUnit.PoundMole, new BaseUnits(amount: AmountOfSubstanceUnit.PoundMole)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +84,22 @@ public AmountOfSubstance(double numericValue, AmountOfSubstanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public AmountOfSubstance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs index 6169214bee..68b1efbe3f 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs @@ -47,7 +47,15 @@ public partial struct AmplitudeRatio : IQuantity, IEquatable static AmplitudeRatio() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.AmplitudeRatio, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.AmplitudeRatio, + new UnitInfo[] { + new UnitInfo(AmplitudeRatioUnit.DecibelMicrovolt, BaseUnits.Undefined), + new UnitInfo(AmplitudeRatioUnit.DecibelMillivolt, BaseUnits.Undefined), + new UnitInfo(AmplitudeRatioUnit.DecibelUnloaded, BaseUnits.Undefined), + new UnitInfo(AmplitudeRatioUnit.DecibelVolt, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +73,22 @@ public AmplitudeRatio(double numericValue, AmplitudeRatioUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public AmplitudeRatio(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs index 76064c41e7..1cf0232fc8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs @@ -47,7 +47,25 @@ public partial struct Angle : IQuantity, IEquatable, IComparab static Angle() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Angle, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Angle, + new UnitInfo[] { + new UnitInfo(AngleUnit.Arcminute, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Arcsecond, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Centiradian, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Deciradian, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Degree, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Gradian, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Microdegree, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Microradian, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Millidegree, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Milliradian, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Nanodegree, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Nanoradian, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Radian, BaseUnits.Undefined), + new UnitInfo(AngleUnit.Revolution, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +83,22 @@ public Angle(double numericValue, AngleUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Angle(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs index 65bf4d8ae8..7dc3400b58 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct ApparentEnergy : IQuantity, IEquatable static ApparentEnergy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ApparentEnergy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ApparentEnergy, + new UnitInfo[] { + new UnitInfo(ApparentEnergyUnit.KilovoltampereHour, BaseUnits.Undefined), + new UnitInfo(ApparentEnergyUnit.MegavoltampereHour, BaseUnits.Undefined), + new UnitInfo(ApparentEnergyUnit.VoltampereHour, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public ApparentEnergy(double numericValue, ApparentEnergyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ApparentEnergy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs index 3e1bb15055..911d7f4b2e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs @@ -47,7 +47,15 @@ public partial struct ApparentPower : IQuantity, IEquatable(QuantityType.ApparentPower, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ApparentPower, + new UnitInfo[] { + new UnitInfo(ApparentPowerUnit.Gigavoltampere, BaseUnits.Undefined), + new UnitInfo(ApparentPowerUnit.Kilovoltampere, BaseUnits.Undefined), + new UnitInfo(ApparentPowerUnit.Megavoltampere, BaseUnits.Undefined), + new UnitInfo(ApparentPowerUnit.Voltampere, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +73,22 @@ public ApparentPower(double numericValue, ApparentPowerUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ApparentPower(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs index 37c4ec5eb6..17d01ef1b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs @@ -47,7 +47,24 @@ public partial struct Area : IQuantity, IEquatable, IComparable, static Area() { BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Area, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Area, + new UnitInfo[] { + new UnitInfo(AreaUnit.Acre, BaseUnits.Undefined), + new UnitInfo(AreaUnit.Hectare, BaseUnits.Undefined), + new UnitInfo(AreaUnit.SquareCentimeter, new BaseUnits(length: LengthUnit.Centimeter)), + new UnitInfo(AreaUnit.SquareDecimeter, new BaseUnits(length: LengthUnit.Decimeter)), + new UnitInfo(AreaUnit.SquareFoot, new BaseUnits(length: LengthUnit.Foot)), + new UnitInfo(AreaUnit.SquareInch, new BaseUnits(length: LengthUnit.Inch)), + new UnitInfo(AreaUnit.SquareKilometer, new BaseUnits(length: LengthUnit.Kilometer)), + new UnitInfo(AreaUnit.SquareMeter, new BaseUnits(length: LengthUnit.Meter)), + new UnitInfo(AreaUnit.SquareMicrometer, new BaseUnits(length: LengthUnit.Micrometer)), + new UnitInfo(AreaUnit.SquareMile, new BaseUnits(length: LengthUnit.Mile)), + new UnitInfo(AreaUnit.SquareMillimeter, new BaseUnits(length: LengthUnit.Millimeter)), + new UnitInfo(AreaUnit.SquareYard, new BaseUnits(length: LengthUnit.Yard)), + new UnitInfo(AreaUnit.UsSurveySquareFoot, new BaseUnits(length: LengthUnit.UsSurveyFoot)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +82,22 @@ public Area(double numericValue, AreaUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Area(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs index 404f4d5e94..05305f8457 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs @@ -47,7 +47,12 @@ public partial struct AreaDensity : IQuantity, IEquatable(QuantityType.AreaDensity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.AreaDensity, + new UnitInfo[] { + new UnitInfo(AreaDensityUnit.KilogramPerSquareMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +70,22 @@ public AreaDensity(double numericValue, AreaDensityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public AreaDensity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs index e1bda697bf..5fc2e7bb6a 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs @@ -47,7 +47,17 @@ public partial struct AreaMomentOfInertia : IQuantity, static AreaMomentOfInertia() { BaseDimensions = new BaseDimensions(4, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.AreaMomentOfInertia, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.AreaMomentOfInertia, + new UnitInfo[] { + new UnitInfo(AreaMomentOfInertiaUnit.CentimeterToTheFourth, BaseUnits.Undefined), + new UnitInfo(AreaMomentOfInertiaUnit.DecimeterToTheFourth, BaseUnits.Undefined), + new UnitInfo(AreaMomentOfInertiaUnit.FootToTheFourth, BaseUnits.Undefined), + new UnitInfo(AreaMomentOfInertiaUnit.InchToTheFourth, BaseUnits.Undefined), + new UnitInfo(AreaMomentOfInertiaUnit.MeterToTheFourth, BaseUnits.Undefined), + new UnitInfo(AreaMomentOfInertiaUnit.MillimeterToTheFourth, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +75,22 @@ public AreaMomentOfInertia(double numericValue, AreaMomentOfInertiaUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public AreaMomentOfInertia(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs index 3e8e0c61ce..ff18ee7359 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs @@ -50,7 +50,37 @@ public partial struct BitRate : IQuantity, IEquatable, ICo static BitRate() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.BitRate, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.BitRate, + new UnitInfo[] { + new UnitInfo(BitRateUnit.BitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.BytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.ExabitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.ExabytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.ExbibitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.ExbibytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.GibibitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.GibibytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.GigabitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.GigabytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.KibibitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.KibibytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.KilobitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.KilobytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.MebibitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.MebibytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.MegabitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.MegabytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.PebibitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.PebibytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.PetabitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.PetabytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.TebibitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.TebibytePerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.TerabitPerSecond, BaseUnits.Undefined), + new UnitInfo(BitRateUnit.TerabytePerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +98,22 @@ public BitRate(decimal numericValue, BitRateUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public BitRate(decimal numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = numericValue; + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs index 1e4cd006aa..c17d30a295 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct BrakeSpecificFuelConsumption : IQuantity(QuantityType.BrakeSpecificFuelConsumption, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.BrakeSpecificFuelConsumption, + new UnitInfo[] { + new UnitInfo(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, BaseUnits.Undefined), + new UnitInfo(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BaseUnits.Undefined), + new UnitInfo(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public BrakeSpecificFuelConsumption(double numericValue, BrakeSpecificFuelConsum _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public BrakeSpecificFuelConsumption(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs index fbecb8d5ad..f83f08fc8e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs @@ -50,7 +50,18 @@ public partial struct Capacitance : IQuantity, IEquatable(QuantityType.Capacitance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Capacitance, + new UnitInfo[] { + new UnitInfo(CapacitanceUnit.Farad, BaseUnits.Undefined), + new UnitInfo(CapacitanceUnit.Kilofarad, BaseUnits.Undefined), + new UnitInfo(CapacitanceUnit.Megafarad, BaseUnits.Undefined), + new UnitInfo(CapacitanceUnit.Microfarad, BaseUnits.Undefined), + new UnitInfo(CapacitanceUnit.Millifarad, BaseUnits.Undefined), + new UnitInfo(CapacitanceUnit.Nanofarad, BaseUnits.Undefined), + new UnitInfo(CapacitanceUnit.Picofarad, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +79,22 @@ public Capacitance(double numericValue, CapacitanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Capacitance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs index 4076e5b95a..b1ab84ad95 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct CoefficientOfThermalExpansion : IQuantity(QuantityType.CoefficientOfThermalExpansion, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.CoefficientOfThermalExpansion, + new UnitInfo[] { + new UnitInfo(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, BaseUnits.Undefined), + new UnitInfo(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, BaseUnits.Undefined), + new UnitInfo(CoefficientOfThermalExpansionUnit.InverseKelvin, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public CoefficientOfThermalExpansion(double numericValue, CoefficientOfThermalEx _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public CoefficientOfThermalExpansion(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs index 880fc956b1..0e366d5ca4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs @@ -50,7 +50,50 @@ public partial struct Density : IQuantity, IEquatable, ICo static Density() { BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Density, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Density, + new UnitInfo[] { + new UnitInfo(DensityUnit.CentigramPerDeciliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.CentigramPerLiter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.CentigramPerMilliliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.DecigramPerDeciliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.DecigramPerLiter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.DecigramPerMilliliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.GramPerCubicCentimeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.GramPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.GramPerCubicMillimeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.GramPerDeciliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.GramPerLiter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.GramPerMilliliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.KilogramPerCubicCentimeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.KilogramPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.KilogramPerCubicMillimeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.KilopoundPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(DensityUnit.KilopoundPerCubicInch, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MicrogramPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MicrogramPerDeciliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MicrogramPerLiter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MicrogramPerMilliliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MilligramPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MilligramPerDeciliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MilligramPerLiter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.MilligramPerMilliliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.NanogramPerDeciliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.NanogramPerLiter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.NanogramPerMilliliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.PicogramPerDeciliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.PicogramPerLiter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.PicogramPerMilliliter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.PoundPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(DensityUnit.PoundPerCubicInch, BaseUnits.Undefined), + new UnitInfo(DensityUnit.PoundPerImperialGallon, BaseUnits.Undefined), + new UnitInfo(DensityUnit.PoundPerUSGallon, BaseUnits.Undefined), + new UnitInfo(DensityUnit.SlugPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(DensityUnit.TonnePerCubicCentimeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.TonnePerCubicMeter, BaseUnits.Undefined), + new UnitInfo(DensityUnit.TonnePerCubicMillimeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +111,22 @@ public Density(double numericValue, DensityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Density(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs index 31032ddab8..2549614c73 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs @@ -47,7 +47,21 @@ public partial struct Duration : IQuantity, IEquatable, static Duration() { BaseDimensions = new BaseDimensions(0, 0, 1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Duration, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Duration, + new UnitInfo[] { + new UnitInfo(DurationUnit.Day, new BaseUnits(time: DurationUnit.Day)), + new UnitInfo(DurationUnit.Hour, new BaseUnits(time: DurationUnit.Hour)), + new UnitInfo(DurationUnit.Microsecond, BaseUnits.Undefined), + new UnitInfo(DurationUnit.Millisecond, BaseUnits.Undefined), + new UnitInfo(DurationUnit.Minute, new BaseUnits(time: DurationUnit.Minute)), + new UnitInfo(DurationUnit.Month30, new BaseUnits(time: DurationUnit.Month30)), + new UnitInfo(DurationUnit.Nanosecond, BaseUnits.Undefined), + new UnitInfo(DurationUnit.Second, new BaseUnits(time: DurationUnit.Second)), + new UnitInfo(DurationUnit.Week, new BaseUnits(time: DurationUnit.Week)), + new UnitInfo(DurationUnit.Year365, new BaseUnits(time: DurationUnit.Year365)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +79,22 @@ public Duration(double numericValue, DurationUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Duration(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs index df25a02dea..5be6567cf8 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs @@ -50,7 +50,17 @@ public partial struct DynamicViscosity : IQuantity, IEquat static DynamicViscosity() { BaseDimensions = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.DynamicViscosity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.DynamicViscosity, + new UnitInfo[] { + new UnitInfo(DynamicViscosityUnit.Centipoise, BaseUnits.Undefined), + new UnitInfo(DynamicViscosityUnit.MicropascalSecond, BaseUnits.Undefined), + new UnitInfo(DynamicViscosityUnit.MillipascalSecond, BaseUnits.Undefined), + new UnitInfo(DynamicViscosityUnit.NewtonSecondPerMeterSquared, BaseUnits.Undefined), + new UnitInfo(DynamicViscosityUnit.PascalSecond, BaseUnits.Undefined), + new UnitInfo(DynamicViscosityUnit.Poise, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +78,22 @@ public DynamicViscosity(double numericValue, DynamicViscosityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public DynamicViscosity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs index c9515ff510..07bfd652c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs @@ -47,7 +47,15 @@ public partial struct ElectricAdmittance : IQuantity, IE static ElectricAdmittance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricAdmittance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricAdmittance, + new UnitInfo[] { + new UnitInfo(ElectricAdmittanceUnit.Microsiemens, BaseUnits.Undefined), + new UnitInfo(ElectricAdmittanceUnit.Millisiemens, BaseUnits.Undefined), + new UnitInfo(ElectricAdmittanceUnit.Nanosiemens, BaseUnits.Undefined), + new UnitInfo(ElectricAdmittanceUnit.Siemens, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +73,22 @@ public ElectricAdmittance(double numericValue, ElectricAdmittanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricAdmittance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs index c7a33053af..7251efcc5c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct ElectricCharge : IQuantity, IEquatable static ElectricCharge() { BaseDimensions = new BaseDimensions(0, 0, 1, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricCharge, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricCharge, + new UnitInfo[] { + new UnitInfo(ElectricChargeUnit.Coulomb, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public ElectricCharge(double numericValue, ElectricChargeUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricCharge(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs index 4c2ceddd8e..e994076ab7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct ElectricChargeDensity : IQuantity(QuantityType.ElectricChargeDensity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricChargeDensity, + new UnitInfo[] { + new UnitInfo(ElectricChargeDensityUnit.CoulombPerCubicMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public ElectricChargeDensity(double numericValue, ElectricChargeDensityUnit unit _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricChargeDensity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs index 1396be33ba..f24eb15fd2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs @@ -50,7 +50,14 @@ public partial struct ElectricConductance : IQuantity, static ElectricConductance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricConductance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricConductance, + new UnitInfo[] { + new UnitInfo(ElectricConductanceUnit.Microsiemens, BaseUnits.Undefined), + new UnitInfo(ElectricConductanceUnit.Millisiemens, BaseUnits.Undefined), + new UnitInfo(ElectricConductanceUnit.Siemens, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +75,22 @@ public ElectricConductance(double numericValue, ElectricConductanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricConductance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs index f9e0ab5e54..48040a33ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct ElectricConductivity : IQuantity static ElectricConductivity() { BaseDimensions = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricConductivity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricConductivity, + new UnitInfo[] { + new UnitInfo(ElectricConductivityUnit.SiemensPerMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public ElectricConductivity(double numericValue, ElectricConductivityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricConductivity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs index 4f888f7d49..cbd98eed77 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs @@ -47,7 +47,19 @@ public partial struct ElectricCurrent : IQuantity, IEquatab static ElectricCurrent() { BaseDimensions = new BaseDimensions(0, 0, 0, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricCurrent, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricCurrent, + new UnitInfo[] { + new UnitInfo(ElectricCurrentUnit.Ampere, new BaseUnits(current: ElectricCurrentUnit.Ampere)), + new UnitInfo(ElectricCurrentUnit.Centiampere, BaseUnits.Undefined), + new UnitInfo(ElectricCurrentUnit.Kiloampere, BaseUnits.Undefined), + new UnitInfo(ElectricCurrentUnit.Megaampere, BaseUnits.Undefined), + new UnitInfo(ElectricCurrentUnit.Microampere, BaseUnits.Undefined), + new UnitInfo(ElectricCurrentUnit.Milliampere, BaseUnits.Undefined), + new UnitInfo(ElectricCurrentUnit.Nanoampere, BaseUnits.Undefined), + new UnitInfo(ElectricCurrentUnit.Picoampere, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +77,22 @@ public ElectricCurrent(double numericValue, ElectricCurrentUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricCurrent(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs index 49aec14988..bc232399c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct ElectricCurrentDensity : IQuantity(QuantityType.ElectricCurrentDensity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricCurrentDensity, + new UnitInfo[] { + new UnitInfo(ElectricCurrentDensityUnit.AmperePerSquareMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public ElectricCurrentDensity(double numericValue, ElectricCurrentDensityUnit un _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricCurrentDensity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs index d939f4b8cd..b2daae8d59 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs @@ -47,7 +47,12 @@ public partial struct ElectricCurrentGradient : IQuantity(QuantityType.ElectricCurrentGradient, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricCurrentGradient, + new UnitInfo[] { + new UnitInfo(ElectricCurrentGradientUnit.AmperePerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +70,22 @@ public ElectricCurrentGradient(double numericValue, ElectricCurrentGradientUnit _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricCurrentGradient(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs index 9006f4da65..657907461e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct ElectricField : IQuantity, IEquatable(QuantityType.ElectricField, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricField, + new UnitInfo[] { + new UnitInfo(ElectricFieldUnit.VoltPerMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public ElectricField(double numericValue, ElectricFieldUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricField(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs index 53ac4b7456..a80a84719a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs @@ -50,7 +50,15 @@ public partial struct ElectricInductance : IQuantity, IE static ElectricInductance() { BaseDimensions = new BaseDimensions(2, 1, -2, -2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricInductance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricInductance, + new UnitInfo[] { + new UnitInfo(ElectricInductanceUnit.Henry, BaseUnits.Undefined), + new UnitInfo(ElectricInductanceUnit.Microhenry, BaseUnits.Undefined), + new UnitInfo(ElectricInductanceUnit.Millihenry, BaseUnits.Undefined), + new UnitInfo(ElectricInductanceUnit.Nanohenry, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +76,22 @@ public ElectricInductance(double numericValue, ElectricInductanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricInductance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs index c5b442e5ee..913b633c43 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs @@ -47,7 +47,16 @@ public partial struct ElectricPotential : IQuantity, IEqu static ElectricPotential() { BaseDimensions = new BaseDimensions(2, 1, -3, -1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricPotential, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricPotential, + new UnitInfo[] { + new UnitInfo(ElectricPotentialUnit.Kilovolt, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialUnit.Megavolt, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialUnit.Microvolt, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialUnit.Millivolt, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialUnit.Volt, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +74,22 @@ public ElectricPotential(double numericValue, ElectricPotentialUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricPotential(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs index a5ec184fe5..0a67038192 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs @@ -47,7 +47,16 @@ public partial struct ElectricPotentialAc : IQuantity, static ElectricPotentialAc() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.ElectricPotentialAc, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricPotentialAc, + new UnitInfo[] { + new UnitInfo(ElectricPotentialAcUnit.KilovoltAc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialAcUnit.MegavoltAc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialAcUnit.MicrovoltAc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialAcUnit.MillivoltAc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialAcUnit.VoltAc, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +74,22 @@ public ElectricPotentialAc(double numericValue, ElectricPotentialAcUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricPotentialAc(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs index bf7d9c94eb..8d8d554cec 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs @@ -47,7 +47,16 @@ public partial struct ElectricPotentialDc : IQuantity, static ElectricPotentialDc() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.ElectricPotentialDc, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricPotentialDc, + new UnitInfo[] { + new UnitInfo(ElectricPotentialDcUnit.KilovoltDc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialDcUnit.MegavoltDc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialDcUnit.MicrovoltDc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialDcUnit.MillivoltDc, BaseUnits.Undefined), + new UnitInfo(ElectricPotentialDcUnit.VoltDc, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +74,22 @@ public ElectricPotentialDc(double numericValue, ElectricPotentialDcUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricPotentialDc(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs index 9175f68aa4..49860c0ca9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs @@ -47,7 +47,16 @@ public partial struct ElectricResistance : IQuantity, IE static ElectricResistance() { BaseDimensions = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricResistance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricResistance, + new UnitInfo[] { + new UnitInfo(ElectricResistanceUnit.Gigaohm, BaseUnits.Undefined), + new UnitInfo(ElectricResistanceUnit.Kiloohm, BaseUnits.Undefined), + new UnitInfo(ElectricResistanceUnit.Megaohm, BaseUnits.Undefined), + new UnitInfo(ElectricResistanceUnit.Milliohm, BaseUnits.Undefined), + new UnitInfo(ElectricResistanceUnit.Ohm, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +74,22 @@ public ElectricResistance(double numericValue, ElectricResistanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricResistance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs index 7e957fe687..c2574027b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs @@ -50,7 +50,25 @@ public partial struct ElectricResistivity : IQuantity, static ElectricResistivity() { BaseDimensions = new BaseDimensions(3, 1, -3, -2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricResistivity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ElectricResistivity, + new UnitInfo[] { + new UnitInfo(ElectricResistivityUnit.KiloohmCentimeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.KiloohmMeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.MegaohmCentimeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.MegaohmMeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.MicroohmCentimeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.MicroohmMeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.MilliohmCentimeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.MilliohmMeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.NanoohmCentimeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.NanoohmMeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.OhmCentimeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.OhmMeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.PicoohmCentimeter, BaseUnits.Undefined), + new UnitInfo(ElectricResistivityUnit.PicoohmMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +86,22 @@ public ElectricResistivity(double numericValue, ElectricResistivityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ElectricResistivity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs index 9bdd17836c..f4c729e4b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs @@ -47,7 +47,34 @@ public partial struct Energy : IQuantity, IEquatable, ICompa static Energy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Energy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Energy, + new UnitInfo[] { + new UnitInfo(EnergyUnit.BritishThermalUnit, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.Calorie, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.DecathermEc, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.DecathermImperial, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.DecathermUs, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.ElectronVolt, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.Erg, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.FootPound, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.GigabritishThermalUnit, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.GigawattHour, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.Joule, new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second)), + new UnitInfo(EnergyUnit.KilobritishThermalUnit, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.Kilocalorie, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.Kilojoule, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.KilowattHour, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.MegabritishThermalUnit, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.Megajoule, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.MegawattHour, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.TerawattHour, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.ThermEc, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.ThermImperial, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.ThermUs, BaseUnits.Undefined), + new UnitInfo(EnergyUnit.WattHour, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +92,22 @@ public Energy(double numericValue, EnergyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Energy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs index 44b10003e7..30c1bbef15 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs @@ -47,7 +47,18 @@ public partial struct Entropy : IQuantity, IEquatable, ICo static Entropy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.Entropy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Entropy, + new UnitInfo[] { + new UnitInfo(EntropyUnit.CaloriePerKelvin, BaseUnits.Undefined), + new UnitInfo(EntropyUnit.JoulePerDegreeCelsius, BaseUnits.Undefined), + new UnitInfo(EntropyUnit.JoulePerKelvin, BaseUnits.Undefined), + new UnitInfo(EntropyUnit.KilocaloriePerKelvin, BaseUnits.Undefined), + new UnitInfo(EntropyUnit.KilojoulePerDegreeCelsius, BaseUnits.Undefined), + new UnitInfo(EntropyUnit.KilojoulePerKelvin, BaseUnits.Undefined), + new UnitInfo(EntropyUnit.MegajoulePerKelvin, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +76,22 @@ public Entropy(double numericValue, EntropyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Entropy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs index e67d019360..fb12c95b3c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs @@ -47,7 +47,24 @@ public partial struct Force : IQuantity, IEquatable, IComparab static Force() { BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Force, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Force, + new UnitInfo[] { + new UnitInfo(ForceUnit.Decanewton, BaseUnits.Undefined), + new UnitInfo(ForceUnit.Dyn, BaseUnits.Undefined), + new UnitInfo(ForceUnit.KilogramForce, BaseUnits.Undefined), + new UnitInfo(ForceUnit.Kilonewton, BaseUnits.Undefined), + new UnitInfo(ForceUnit.KiloPond, BaseUnits.Undefined), + new UnitInfo(ForceUnit.Meganewton, BaseUnits.Undefined), + new UnitInfo(ForceUnit.Micronewton, BaseUnits.Undefined), + new UnitInfo(ForceUnit.Millinewton, BaseUnits.Undefined), + new UnitInfo(ForceUnit.Newton, BaseUnits.Undefined), + new UnitInfo(ForceUnit.OunceForce, BaseUnits.Undefined), + new UnitInfo(ForceUnit.Poundal, BaseUnits.Undefined), + new UnitInfo(ForceUnit.PoundForce, BaseUnits.Undefined), + new UnitInfo(ForceUnit.TonneForce, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +82,22 @@ public Force(double numericValue, ForceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Force(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs index 25a0877cbe..6652f3e503 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs @@ -47,7 +47,22 @@ public partial struct ForceChangeRate : IQuantity, IEquatab static ForceChangeRate() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ForceChangeRate, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ForceChangeRate, + new UnitInfo[] { + new UnitInfo(ForceChangeRateUnit.CentinewtonPerSecond, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.DecanewtonPerMinute, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.DecanewtonPerSecond, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.DecinewtonPerSecond, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.KilonewtonPerMinute, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.KilonewtonPerSecond, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.MicronewtonPerSecond, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.MillinewtonPerSecond, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.NanonewtonPerSecond, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.NewtonPerMinute, BaseUnits.Undefined), + new UnitInfo(ForceChangeRateUnit.NewtonPerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +80,22 @@ public ForceChangeRate(double numericValue, ForceChangeRateUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ForceChangeRate(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs index cf92627f8d..9443002d63 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs @@ -47,7 +47,20 @@ public partial struct ForcePerLength : IQuantity, IEquatable static ForcePerLength() { BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ForcePerLength, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ForcePerLength, + new UnitInfo[] { + new UnitInfo(ForcePerLengthUnit.CentinewtonPerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.DecinewtonPerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.KilogramForcePerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.KilonewtonPerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.MeganewtonPerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.MicronewtonPerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.MillinewtonPerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.NanonewtonPerMeter, BaseUnits.Undefined), + new UnitInfo(ForcePerLengthUnit.NewtonPerMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +78,22 @@ public ForcePerLength(double numericValue, ForcePerLengthUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ForcePerLength(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs index eea53375ce..2fb8a350fc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs @@ -47,7 +47,20 @@ public partial struct Frequency : IQuantity, IEquatable(QuantityType.Frequency, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Frequency, + new UnitInfo[] { + new UnitInfo(FrequencyUnit.BeatPerMinute, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.CyclePerHour, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.CyclePerMinute, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.Gigahertz, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.Hertz, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.Kilohertz, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.Megahertz, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.RadianPerSecond, BaseUnits.Undefined), + new UnitInfo(FrequencyUnit.Terahertz, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +78,22 @@ public Frequency(double numericValue, FrequencyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Frequency(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs index 7a267b6070..3946bdb158 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs @@ -47,7 +47,29 @@ public partial struct HeatFlux : IQuantity, IEquatable, static HeatFlux() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.HeatFlux, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.HeatFlux, + new UnitInfo[] { + new UnitInfo(HeatFluxUnit.BtuPerHourSquareFoot, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.BtuPerMinuteSquareFoot, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.BtuPerSecondSquareFoot, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.BtuPerSecondSquareInch, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.CaloriePerSecondSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.CentiwattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.DeciwattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.KilocaloriePerHourSquareMeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.KilowattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.MicrowattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.MilliwattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.NanowattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.PoundForcePerFootSecond, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.PoundPerSecondCubed, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.WattPerSquareFoot, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.WattPerSquareInch, BaseUnits.Undefined), + new UnitInfo(HeatFluxUnit.WattPerSquareMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +87,22 @@ public HeatFlux(double numericValue, HeatFluxUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public HeatFlux(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs index 379bca138b..d60a5f1d39 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs @@ -47,7 +47,13 @@ public partial struct HeatTransferCoefficient : IQuantity(QuantityType.HeatTransferCoefficient, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.HeatTransferCoefficient, + new UnitInfo[] { + new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, BaseUnits.Undefined), + new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +71,22 @@ public HeatTransferCoefficient(double numericValue, HeatTransferCoefficientUnit _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public HeatTransferCoefficient(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs index 12786090d1..c03f3b238f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs @@ -50,7 +50,15 @@ public partial struct Illuminance : IQuantity, IEquatable(QuantityType.Illuminance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Illuminance, + new UnitInfo[] { + new UnitInfo(IlluminanceUnit.Kilolux, BaseUnits.Undefined), + new UnitInfo(IlluminanceUnit.Lux, BaseUnits.Undefined), + new UnitInfo(IlluminanceUnit.Megalux, BaseUnits.Undefined), + new UnitInfo(IlluminanceUnit.Millilux, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +76,22 @@ public Illuminance(double numericValue, IlluminanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Illuminance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs index 94dfd1b689..9846019fd4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs @@ -47,7 +47,37 @@ public partial struct Information : IQuantity, IEquatable(QuantityType.Information, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Information, + new UnitInfo[] { + new UnitInfo(InformationUnit.Bit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Byte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Exabit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Exabyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Exbibit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Exbibyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Gibibit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Gibibyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Gigabit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Gigabyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Kibibit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Kibibyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Kilobit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Kilobyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Mebibit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Mebibyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Megabit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Megabyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Pebibit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Pebibyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Petabit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Petabyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Tebibit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Tebibyte, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Terabit, BaseUnits.Undefined), + new UnitInfo(InformationUnit.Terabyte, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +95,22 @@ public Information(decimal numericValue, InformationUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Information(decimal numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = numericValue; + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs index 3188e2f0aa..9112a8dac9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs @@ -47,7 +47,25 @@ public partial struct Irradiance : IQuantity, IEquatable(QuantityType.Irradiance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Irradiance, + new UnitInfo[] { + new UnitInfo(IrradianceUnit.KilowattPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.KilowattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.MegawattPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.MegawattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.MicrowattPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.MicrowattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.MilliwattPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.MilliwattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.NanowattPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.NanowattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.PicowattPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.PicowattPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.WattPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradianceUnit.WattPerSquareMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +83,22 @@ public Irradiance(double numericValue, IrradianceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Irradiance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs index 29e85434e6..0b3e47a2ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs @@ -50,7 +50,17 @@ public partial struct Irradiation : IQuantity, IEquatable(QuantityType.Irradiation, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Irradiation, + new UnitInfo[] { + new UnitInfo(IrradiationUnit.JoulePerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(IrradiationUnit.JoulePerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradiationUnit.JoulePerSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(IrradiationUnit.KilojoulePerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradiationUnit.KilowattHourPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(IrradiationUnit.WattHourPerSquareMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +78,22 @@ public Irradiation(double numericValue, IrradiationUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Irradiation(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs index 257179e68a..9b9c310377 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs @@ -50,7 +50,19 @@ public partial struct KinematicViscosity : IQuantity, IE static KinematicViscosity() { BaseDimensions = new BaseDimensions(2, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.KinematicViscosity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.KinematicViscosity, + new UnitInfo[] { + new UnitInfo(KinematicViscosityUnit.Centistokes, BaseUnits.Undefined), + new UnitInfo(KinematicViscosityUnit.Decistokes, BaseUnits.Undefined), + new UnitInfo(KinematicViscosityUnit.Kilostokes, BaseUnits.Undefined), + new UnitInfo(KinematicViscosityUnit.Microstokes, BaseUnits.Undefined), + new UnitInfo(KinematicViscosityUnit.Millistokes, BaseUnits.Undefined), + new UnitInfo(KinematicViscosityUnit.Nanostokes, BaseUnits.Undefined), + new UnitInfo(KinematicViscosityUnit.SquareMeterPerSecond, BaseUnits.Undefined), + new UnitInfo(KinematicViscosityUnit.Stokes, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +80,22 @@ public KinematicViscosity(double numericValue, KinematicViscosityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public KinematicViscosity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs index 1ffbbaeb13..51cbacd6c3 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs @@ -47,7 +47,12 @@ public partial struct LapseRate : IQuantity, IEquatable(QuantityType.LapseRate, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.LapseRate, + new UnitInfo[] { + new UnitInfo(LapseRateUnit.DegreeCelsiusPerKilometer, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +70,22 @@ public LapseRate(double numericValue, LapseRateUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public LapseRate(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs index 4087edce83..88eb48c964 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs @@ -47,7 +47,33 @@ public partial struct Length : IQuantity, IEquatable, ICompa static Length() { BaseDimensions = new BaseDimensions(1, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Length, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Length, + new UnitInfo[] { + new UnitInfo(LengthUnit.Centimeter, BaseUnits.Undefined), + new UnitInfo(LengthUnit.Decimeter, BaseUnits.Undefined), + new UnitInfo(LengthUnit.DtpPica, new BaseUnits(length: LengthUnit.DtpPica)), + new UnitInfo(LengthUnit.DtpPoint, new BaseUnits(length: LengthUnit.DtpPoint)), + new UnitInfo(LengthUnit.Fathom, new BaseUnits(length: LengthUnit.Fathom)), + new UnitInfo(LengthUnit.Foot, new BaseUnits(length: LengthUnit.Foot)), + new UnitInfo(LengthUnit.Inch, new BaseUnits(length: LengthUnit.Inch)), + new UnitInfo(LengthUnit.Kilometer, BaseUnits.Undefined), + new UnitInfo(LengthUnit.Meter, new BaseUnits(length: LengthUnit.Meter)), + new UnitInfo(LengthUnit.Microinch, new BaseUnits(length: LengthUnit.Microinch)), + new UnitInfo(LengthUnit.Micrometer, BaseUnits.Undefined), + new UnitInfo(LengthUnit.Mil, new BaseUnits(length: LengthUnit.Mil)), + new UnitInfo(LengthUnit.Mile, new BaseUnits(length: LengthUnit.Mile)), + new UnitInfo(LengthUnit.Millimeter, BaseUnits.Undefined), + new UnitInfo(LengthUnit.Nanometer, BaseUnits.Undefined), + new UnitInfo(LengthUnit.NauticalMile, new BaseUnits(length: LengthUnit.NauticalMile)), + new UnitInfo(LengthUnit.PrinterPica, new BaseUnits(length: LengthUnit.PrinterPica)), + new UnitInfo(LengthUnit.PrinterPoint, new BaseUnits(length: LengthUnit.PrinterPoint)), + new UnitInfo(LengthUnit.Shackle, new BaseUnits(length: LengthUnit.Shackle)), + new UnitInfo(LengthUnit.Twip, new BaseUnits(length: LengthUnit.Twip)), + new UnitInfo(LengthUnit.UsSurveyFoot, new BaseUnits(length: LengthUnit.UsSurveyFoot)), + new UnitInfo(LengthUnit.Yard, new BaseUnits(length: LengthUnit.Yard)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +91,22 @@ public Length(double numericValue, LengthUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Length(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs index 8cc1f7fc55..4ebe23cef1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs @@ -47,7 +47,13 @@ public partial struct Level : IQuantity, IEquatable, IComparab static Level() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Level, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Level, + new UnitInfo[] { + new UnitInfo(LevelUnit.Decibel, BaseUnits.Undefined), + new UnitInfo(LevelUnit.Neper, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +71,22 @@ public Level(double numericValue, LevelUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Level(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs index de996e2362..040e9c8315 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs @@ -50,7 +50,14 @@ public partial struct LinearDensity : IQuantity, IEquatable(QuantityType.LinearDensity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.LinearDensity, + new UnitInfo[] { + new UnitInfo(LinearDensityUnit.GramPerMeter, BaseUnits.Undefined), + new UnitInfo(LinearDensityUnit.KilogramPerMeter, BaseUnits.Undefined), + new UnitInfo(LinearDensityUnit.PoundPerFoot, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +75,22 @@ public LinearDensity(double numericValue, LinearDensityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public LinearDensity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs index f35a607a79..b1d426416c 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct LuminousFlux : IQuantity, IEquatable(QuantityType.LuminousFlux, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.LuminousFlux, + new UnitInfo[] { + new UnitInfo(LuminousFluxUnit.Lumen, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public LuminousFlux(double numericValue, LuminousFluxUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public LuminousFlux(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs index b882f914e5..fcef9ceecc 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct LuminousIntensity : IQuantity, IEqu static LuminousIntensity() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); - Info = new QuantityInfo(QuantityType.LuminousIntensity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.LuminousIntensity, + new UnitInfo[] { + new UnitInfo(LuminousIntensityUnit.Candela, new BaseUnits(luminousIntensity: LuminousIntensityUnit.Candela)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public LuminousIntensity(double numericValue, LuminousIntensityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public LuminousIntensity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs index 303459d9c4..98f6fae710 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs @@ -50,7 +50,15 @@ public partial struct MagneticField : IQuantity, IEquatable(QuantityType.MagneticField, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MagneticField, + new UnitInfo[] { + new UnitInfo(MagneticFieldUnit.Microtesla, BaseUnits.Undefined), + new UnitInfo(MagneticFieldUnit.Millitesla, BaseUnits.Undefined), + new UnitInfo(MagneticFieldUnit.Nanotesla, BaseUnits.Undefined), + new UnitInfo(MagneticFieldUnit.Tesla, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +76,22 @@ public MagneticField(double numericValue, MagneticFieldUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MagneticField(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs index b8b15c7818..9823ef4b9c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct MagneticFlux : IQuantity, IEquatable(QuantityType.MagneticFlux, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MagneticFlux, + new UnitInfo[] { + new UnitInfo(MagneticFluxUnit.Weber, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public MagneticFlux(double numericValue, MagneticFluxUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MagneticFlux(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs index 574b89f106..457d78c8db 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct Magnetization : IQuantity, IEquatable(QuantityType.Magnetization, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Magnetization, + new UnitInfo[] { + new UnitInfo(MagnetizationUnit.AmperePerMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public Magnetization(double numericValue, MagnetizationUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Magnetization(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs index d4b2fa7fc3..4d1c556741 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs @@ -47,7 +47,34 @@ public partial struct Mass : IQuantity, IEquatable, IComparable, static Mass() { BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Mass, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Mass, + new UnitInfo[] { + new UnitInfo(MassUnit.Centigram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Decagram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Decigram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Grain, new BaseUnits(mass: MassUnit.Grain)), + new UnitInfo(MassUnit.Gram, new BaseUnits(mass: MassUnit.Gram)), + new UnitInfo(MassUnit.Hectogram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Kilogram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Kilopound, BaseUnits.Undefined), + new UnitInfo(MassUnit.Kilotonne, BaseUnits.Undefined), + new UnitInfo(MassUnit.LongHundredweight, new BaseUnits(mass: MassUnit.LongHundredweight)), + new UnitInfo(MassUnit.LongTon, new BaseUnits(mass: MassUnit.LongTon)), + new UnitInfo(MassUnit.Megapound, BaseUnits.Undefined), + new UnitInfo(MassUnit.Megatonne, BaseUnits.Undefined), + new UnitInfo(MassUnit.Microgram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Milligram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Nanogram, BaseUnits.Undefined), + new UnitInfo(MassUnit.Ounce, new BaseUnits(mass: MassUnit.Ounce)), + new UnitInfo(MassUnit.Pound, new BaseUnits(mass: MassUnit.Pound)), + new UnitInfo(MassUnit.ShortHundredweight, new BaseUnits(mass: MassUnit.ShortHundredweight)), + new UnitInfo(MassUnit.ShortTon, new BaseUnits(mass: MassUnit.ShortTon)), + new UnitInfo(MassUnit.Slug, new BaseUnits(mass: MassUnit.Slug)), + new UnitInfo(MassUnit.Stone, new BaseUnits(mass: MassUnit.Stone)), + new UnitInfo(MassUnit.Tonne, new BaseUnits(mass: MassUnit.Tonne)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +92,22 @@ public Mass(double numericValue, MassUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Mass(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs index ec6ea3fa05..b9738b9f47 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs @@ -47,7 +47,42 @@ public partial struct MassFlow : IQuantity, IEquatable, static MassFlow() { BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MassFlow, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MassFlow, + new UnitInfo[] { + new UnitInfo(MassFlowUnit.CentigramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.CentigramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.DecagramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.DecagramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.DecigramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.DecigramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.GramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.GramPerHour, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.GramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.HectogramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.HectogramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.KilogramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.KilogramPerHour, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.KilogramPerMinute, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.KilogramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MegagramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MegapoundPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MegapoundPerHour, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MegapoundPerMinute, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MicrogramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MicrogramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MilligramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.MilligramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.NanogramPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.NanogramPerSecond, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.PoundPerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.PoundPerHour, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.PoundPerMinute, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.ShortTonPerHour, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.TonnePerDay, BaseUnits.Undefined), + new UnitInfo(MassFlowUnit.TonnePerHour, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +100,22 @@ public MassFlow(double numericValue, MassFlowUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MassFlow(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs index 43778a88d0..0dff7ac0dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs @@ -47,7 +47,13 @@ public partial struct MassFlux : IQuantity, IEquatable, static MassFlux() { BaseDimensions = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MassFlux, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MassFlux, + new UnitInfo[] { + new UnitInfo(MassFluxUnit.GramPerSecondPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(MassFluxUnit.KilogramPerSecondPerSquareMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +71,22 @@ public MassFlux(double numericValue, MassFluxUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MassFlux(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs index 180fd5ead3..2ddeb30cd9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs @@ -47,7 +47,39 @@ public partial struct MassMomentOfInertia : IQuantity, static MassMomentOfInertia() { BaseDimensions = new BaseDimensions(2, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MassMomentOfInertia, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MassMomentOfInertia, + new UnitInfo[] { + new UnitInfo(MassMomentOfInertiaUnit.GramSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.GramSquareDecimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.GramSquareMeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.GramSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilogramSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilogramSquareDecimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilogramSquareMeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilogramSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilotonneSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilotonneSquareDecimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilotonneSquareMeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.KilotonneSquareMilimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MegatonneSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MegatonneSquareDecimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MegatonneSquareMeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MegatonneSquareMilimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MilligramSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MilligramSquareDecimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MilligramSquareMeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.MilligramSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.PoundSquareFoot, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.PoundSquareInch, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.SlugSquareFoot, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.SlugSquareInch, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.TonneSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.TonneSquareDecimeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMeter, BaseUnits.Undefined), + new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMilimeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +97,22 @@ public MassMomentOfInertia(double numericValue, MassMomentOfInertiaUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MassMomentOfInertia(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs index 31b853d795..086e514f40 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct MolarEnergy : IQuantity, IEquatable(QuantityType.MolarEnergy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MolarEnergy, + new UnitInfo[] { + new UnitInfo(MolarEnergyUnit.JoulePerMole, BaseUnits.Undefined), + new UnitInfo(MolarEnergyUnit.KilojoulePerMole, BaseUnits.Undefined), + new UnitInfo(MolarEnergyUnit.MegajoulePerMole, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public MolarEnergy(double numericValue, MolarEnergyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MolarEnergy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs index 4992131897..47bafbacee 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct MolarEntropy : IQuantity, IEquatable(QuantityType.MolarEntropy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MolarEntropy, + new UnitInfo[] { + new UnitInfo(MolarEntropyUnit.JoulePerMoleKelvin, BaseUnits.Undefined), + new UnitInfo(MolarEntropyUnit.KilojoulePerMoleKelvin, BaseUnits.Undefined), + new UnitInfo(MolarEntropyUnit.MegajoulePerMoleKelvin, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public MolarEntropy(double numericValue, MolarEntropyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MolarEntropy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs index 480a3ea3ad..d15e4c5419 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs @@ -47,7 +47,23 @@ public partial struct MolarMass : IQuantity, IEquatable(QuantityType.MolarMass, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.MolarMass, + new UnitInfo[] { + new UnitInfo(MolarMassUnit.CentigramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.DecagramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.DecigramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.GramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.HectogramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.KilogramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.KilopoundPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.MegapoundPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.MicrogramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.MilligramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.NanogramPerMole, BaseUnits.Undefined), + new UnitInfo(MolarMassUnit.PoundPerMole, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +81,22 @@ public MolarMass(double numericValue, MolarMassUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public MolarMass(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs index d495115d3a..12c5652138 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs @@ -50,7 +50,19 @@ public partial struct Molarity : IQuantity, IEquatable, static Molarity() { BaseDimensions = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0); - Info = new QuantityInfo(QuantityType.Molarity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Molarity, + new UnitInfo[] { + new UnitInfo(MolarityUnit.CentimolesPerLiter, BaseUnits.Undefined), + new UnitInfo(MolarityUnit.DecimolesPerLiter, BaseUnits.Undefined), + new UnitInfo(MolarityUnit.MicromolesPerLiter, BaseUnits.Undefined), + new UnitInfo(MolarityUnit.MillimolesPerLiter, BaseUnits.Undefined), + new UnitInfo(MolarityUnit.MolesPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(MolarityUnit.MolesPerLiter, BaseUnits.Undefined), + new UnitInfo(MolarityUnit.NanomolesPerLiter, BaseUnits.Undefined), + new UnitInfo(MolarityUnit.PicomolesPerLiter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +80,22 @@ public Molarity(double numericValue, MolarityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Molarity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs index 129eba6016..6b99f114a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct Permeability : IQuantity, IEquatable(QuantityType.Permeability, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Permeability, + new UnitInfo[] { + new UnitInfo(PermeabilityUnit.HenryPerMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public Permeability(double numericValue, PermeabilityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Permeability(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs index a855fe78dc..651ffa64c3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct Permittivity : IQuantity, IEquatable(QuantityType.Permittivity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Permittivity, + new UnitInfo[] { + new UnitInfo(PermittivityUnit.FaradPerMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public Permittivity(double numericValue, PermittivityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Permittivity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs index 3d05be4a37..608a07212e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs @@ -47,7 +47,31 @@ public partial struct Power : IQuantity, IEquatable, IComparab static Power() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Power, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Power, + new UnitInfo[] { + new UnitInfo(PowerUnit.BoilerHorsepower, BaseUnits.Undefined), + new UnitInfo(PowerUnit.BritishThermalUnitPerHour, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Decawatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Deciwatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.ElectricalHorsepower, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Femtowatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Gigawatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.HydraulicHorsepower, BaseUnits.Undefined), + new UnitInfo(PowerUnit.KilobritishThermalUnitPerHour, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Kilowatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.MechanicalHorsepower, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Megawatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.MetricHorsepower, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Microwatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Milliwatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Nanowatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Petawatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Picowatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Terawatt, BaseUnits.Undefined), + new UnitInfo(PowerUnit.Watt, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +89,22 @@ public Power(decimal numericValue, PowerUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Power(decimal numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = numericValue; + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs index 54c7acfaa3..c26983c83c 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs @@ -47,7 +47,55 @@ public partial struct PowerDensity : IQuantity, IEquatable(QuantityType.PowerDensity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.PowerDensity, + new UnitInfo[] { + new UnitInfo(PowerDensityUnit.DecawattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.DecawattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.DecawattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.DecawattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.DeciwattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.DeciwattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.DeciwattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.DeciwattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.GigawattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.GigawattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.GigawattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.GigawattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.KilowattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.KilowattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.KilowattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.KilowattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MegawattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MegawattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MegawattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MegawattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MicrowattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MicrowattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MicrowattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MicrowattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MilliwattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MilliwattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MilliwattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.MilliwattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.NanowattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.NanowattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.NanowattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.NanowattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.PicowattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.PicowattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.PicowattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.PicowattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.TerawattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.TerawattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.TerawattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.TerawattPerLiter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.WattPerCubicFoot, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.WattPerCubicInch, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.WattPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(PowerDensityUnit.WattPerLiter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +113,22 @@ public PowerDensity(double numericValue, PowerDensityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public PowerDensity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs index d466a60fc7..2e51a2d276 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs @@ -47,7 +47,13 @@ public partial struct PowerRatio : IQuantity, IEquatable(QuantityType.PowerRatio, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.PowerRatio, + new UnitInfo[] { + new UnitInfo(PowerRatioUnit.DecibelMilliwatt, BaseUnits.Undefined), + new UnitInfo(PowerRatioUnit.DecibelWatt, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +71,22 @@ public PowerRatio(double numericValue, PowerRatioUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public PowerRatio(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs index fe11e822e2..5ff7738184 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs @@ -47,7 +47,53 @@ public partial struct Pressure : IQuantity, IEquatable, static Pressure() { BaseDimensions = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Pressure, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Pressure, + new UnitInfo[] { + new UnitInfo(PressureUnit.Atmosphere, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Bar, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Centibar, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Decapascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Decibar, BaseUnits.Undefined), + new UnitInfo(PressureUnit.DynePerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.FootOfHead, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Gigapascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Hectopascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.InchOfMercury, BaseUnits.Undefined), + new UnitInfo(PressureUnit.InchOfWaterColumn, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Kilobar, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilogramForcePerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilogramForcePerSquareMeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilogramForcePerSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilonewtonPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilonewtonPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilonewtonPerSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Kilopascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilopoundForcePerSquareFoot, BaseUnits.Undefined), + new UnitInfo(PressureUnit.KilopoundForcePerSquareInch, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Megabar, BaseUnits.Undefined), + new UnitInfo(PressureUnit.MeganewtonPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Megapascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.MeterOfHead, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Microbar, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Micropascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Millibar, BaseUnits.Undefined), + new UnitInfo(PressureUnit.MillimeterOfMercury, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Millipascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.NewtonPerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.NewtonPerSquareMeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.NewtonPerSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Pascal, BaseUnits.Undefined), + new UnitInfo(PressureUnit.PoundForcePerSquareFoot, BaseUnits.Undefined), + new UnitInfo(PressureUnit.PoundForcePerSquareInch, BaseUnits.Undefined), + new UnitInfo(PressureUnit.PoundPerInchSecondSquared, BaseUnits.Undefined), + new UnitInfo(PressureUnit.TechnicalAtmosphere, BaseUnits.Undefined), + new UnitInfo(PressureUnit.TonneForcePerSquareCentimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.TonneForcePerSquareMeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.TonneForcePerSquareMillimeter, BaseUnits.Undefined), + new UnitInfo(PressureUnit.Torr, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +111,22 @@ public Pressure(double numericValue, PressureUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Pressure(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs index 5fbc74ba44..f332ba8e60 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs @@ -47,7 +47,18 @@ public partial struct PressureChangeRate : IQuantity, IE static PressureChangeRate() { BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.PressureChangeRate, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.PressureChangeRate, + new UnitInfo[] { + new UnitInfo(PressureChangeRateUnit.AtmospherePerSecond, BaseUnits.Undefined), + new UnitInfo(PressureChangeRateUnit.KilopascalPerMinute, BaseUnits.Undefined), + new UnitInfo(PressureChangeRateUnit.KilopascalPerSecond, BaseUnits.Undefined), + new UnitInfo(PressureChangeRateUnit.MegapascalPerMinute, BaseUnits.Undefined), + new UnitInfo(PressureChangeRateUnit.MegapascalPerSecond, BaseUnits.Undefined), + new UnitInfo(PressureChangeRateUnit.PascalPerMinute, BaseUnits.Undefined), + new UnitInfo(PressureChangeRateUnit.PascalPerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +76,22 @@ public PressureChangeRate(double numericValue, PressureChangeRateUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public PressureChangeRate(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs index 3a7f282ccb..c750dcd329 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs @@ -47,7 +47,17 @@ public partial struct Ratio : IQuantity, IEquatable, IComparab static Ratio() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Ratio, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Ratio, + new UnitInfo[] { + new UnitInfo(RatioUnit.DecimalFraction, BaseUnits.Undefined), + new UnitInfo(RatioUnit.PartPerBillion, BaseUnits.Undefined), + new UnitInfo(RatioUnit.PartPerMillion, BaseUnits.Undefined), + new UnitInfo(RatioUnit.PartPerThousand, BaseUnits.Undefined), + new UnitInfo(RatioUnit.PartPerTrillion, BaseUnits.Undefined), + new UnitInfo(RatioUnit.Percent, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +75,22 @@ public Ratio(double numericValue, RatioUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Ratio(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs index 1e90b04e81..402e176d8b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct ReactiveEnergy : IQuantity, IEquatable static ReactiveEnergy() { BaseDimensions = new BaseDimensions(2, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ReactiveEnergy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ReactiveEnergy, + new UnitInfo[] { + new UnitInfo(ReactiveEnergyUnit.KilovoltampereReactiveHour, BaseUnits.Undefined), + new UnitInfo(ReactiveEnergyUnit.MegavoltampereReactiveHour, BaseUnits.Undefined), + new UnitInfo(ReactiveEnergyUnit.VoltampereReactiveHour, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public ReactiveEnergy(double numericValue, ReactiveEnergyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ReactiveEnergy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs index d592f5ea84..8c5d062bad 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs @@ -47,7 +47,15 @@ public partial struct ReactivePower : IQuantity, IEquatable(QuantityType.ReactivePower, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ReactivePower, + new UnitInfo[] { + new UnitInfo(ReactivePowerUnit.GigavoltampereReactive, BaseUnits.Undefined), + new UnitInfo(ReactivePowerUnit.KilovoltampereReactive, BaseUnits.Undefined), + new UnitInfo(ReactivePowerUnit.MegavoltampereReactive, BaseUnits.Undefined), + new UnitInfo(ReactivePowerUnit.VoltampereReactive, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +73,22 @@ public ReactivePower(double numericValue, ReactivePowerUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ReactivePower(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs index 2e3e75aaa6..38c7f036db 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct RotationalAcceleration : IQuantity(QuantityType.RotationalAcceleration, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.RotationalAcceleration, + new UnitInfo[] { + new UnitInfo(RotationalAccelerationUnit.DegreePerSecondSquared, BaseUnits.Undefined), + new UnitInfo(RotationalAccelerationUnit.RadianPerSecondSquared, BaseUnits.Undefined), + new UnitInfo(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public RotationalAcceleration(double numericValue, RotationalAccelerationUnit un _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public RotationalAcceleration(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs index 1844dace9a..d5c3072ca6 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs @@ -47,7 +47,24 @@ public partial struct RotationalSpeed : IQuantity, IEquatab static RotationalSpeed() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.RotationalSpeed, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.RotationalSpeed, + new UnitInfo[] { + new UnitInfo(RotationalSpeedUnit.CentiradianPerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.DeciradianPerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.DegreePerMinute, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.DegreePerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.MicrodegreePerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.MicroradianPerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.MillidegreePerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.MilliradianPerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.NanodegreePerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.NanoradianPerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.RadianPerSecond, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.RevolutionPerMinute, BaseUnits.Undefined), + new UnitInfo(RotationalSpeedUnit.RevolutionPerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +82,22 @@ public RotationalSpeed(double numericValue, RotationalSpeedUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public RotationalSpeed(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs index abedfb2c68..28af2f4202 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct RotationalStiffness : IQuantity, static RotationalStiffness() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.RotationalStiffness, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.RotationalStiffness, + new UnitInfo[] { + new UnitInfo(RotationalStiffnessUnit.KilonewtonMeterPerRadian, BaseUnits.Undefined), + new UnitInfo(RotationalStiffnessUnit.MeganewtonMeterPerRadian, BaseUnits.Undefined), + new UnitInfo(RotationalStiffnessUnit.NewtonMeterPerRadian, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public RotationalStiffness(double numericValue, RotationalStiffnessUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public RotationalStiffness(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs index e30673ef5a..06c41893d9 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct RotationalStiffnessPerLength : IQuantity(QuantityType.RotationalStiffnessPerLength, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.RotationalStiffnessPerLength, + new UnitInfo[] { + new UnitInfo(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, BaseUnits.Undefined), + new UnitInfo(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, BaseUnits.Undefined), + new UnitInfo(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public RotationalStiffnessPerLength(double numericValue, RotationalStiffnessPerL _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public RotationalStiffnessPerLength(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs index ebab308d33..219c7caa30 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs @@ -50,7 +50,12 @@ public partial struct SolidAngle : IQuantity, IEquatable(QuantityType.SolidAngle, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.SolidAngle, + new UnitInfo[] { + new UnitInfo(SolidAngleUnit.Steradian, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +73,22 @@ public SolidAngle(double numericValue, SolidAngleUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public SolidAngle(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs index 265f38a41c..270f96e971 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs @@ -50,7 +50,20 @@ public partial struct SpecificEnergy : IQuantity, IEquatable static SpecificEnergy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificEnergy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.SpecificEnergy, + new UnitInfo[] { + new UnitInfo(SpecificEnergyUnit.BtuPerPound, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.CaloriePerGram, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.JoulePerKilogram, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.KilocaloriePerGram, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.KilojoulePerKilogram, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.KilowattHourPerKilogram, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.MegajoulePerKilogram, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.MegawattHourPerKilogram, BaseUnits.Undefined), + new UnitInfo(SpecificEnergyUnit.WattHourPerKilogram, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +81,22 @@ public SpecificEnergy(double numericValue, SpecificEnergyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public SpecificEnergy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs index c3ac785438..db5efec870 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs @@ -47,7 +47,19 @@ public partial struct SpecificEntropy : IQuantity, IEquatab static SpecificEntropy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificEntropy, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.SpecificEntropy, + new UnitInfo[] { + new UnitInfo(SpecificEntropyUnit.CaloriePerGramKelvin, BaseUnits.Undefined), + new UnitInfo(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, BaseUnits.Undefined), + new UnitInfo(SpecificEntropyUnit.JoulePerKilogramKelvin, BaseUnits.Undefined), + new UnitInfo(SpecificEntropyUnit.KilocaloriePerGramKelvin, BaseUnits.Undefined), + new UnitInfo(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, BaseUnits.Undefined), + new UnitInfo(SpecificEntropyUnit.KilojoulePerKilogramKelvin, BaseUnits.Undefined), + new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, BaseUnits.Undefined), + new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramKelvin, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +77,22 @@ public SpecificEntropy(double numericValue, SpecificEntropyUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public SpecificEntropy(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs index aa44796f82..d06acab3c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs @@ -47,7 +47,14 @@ public partial struct SpecificVolume : IQuantity, IEquatable static SpecificVolume() { BaseDimensions = new BaseDimensions(3, -1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificVolume, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.SpecificVolume, + new UnitInfo[] { + new UnitInfo(SpecificVolumeUnit.CubicFootPerPound, BaseUnits.Undefined), + new UnitInfo(SpecificVolumeUnit.CubicMeterPerKilogram, BaseUnits.Undefined), + new UnitInfo(SpecificVolumeUnit.MillicubicMeterPerKilogram, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +72,22 @@ public SpecificVolume(double numericValue, SpecificVolumeUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public SpecificVolume(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs index bf487f6e32..a5957881a3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs @@ -50,7 +50,28 @@ public partial struct SpecificWeight : IQuantity, IEquatable static SpecificWeight() { BaseDimensions = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificWeight, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.SpecificWeight, + new UnitInfo[] { + new UnitInfo(SpecificWeightUnit.KilogramForcePerCubicCentimeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.KilogramForcePerCubicMeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.KilogramForcePerCubicMillimeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.KilonewtonPerCubicCentimeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.KilonewtonPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.KilonewtonPerCubicMillimeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.KilopoundForcePerCubicFoot, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.KilopoundForcePerCubicInch, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.MeganewtonPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.NewtonPerCubicCentimeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.NewtonPerCubicMeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.NewtonPerCubicMillimeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.PoundForcePerCubicFoot, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.PoundForcePerCubicInch, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.TonneForcePerCubicCentimeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMeter, BaseUnits.Undefined), + new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMillimeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +89,22 @@ public SpecificWeight(double numericValue, SpecificWeightUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public SpecificWeight(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs index b403426fbc..aa414253c3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs @@ -47,7 +47,43 @@ public partial struct Speed : IQuantity, IEquatable, IComparab static Speed() { BaseDimensions = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Speed, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Speed, + new UnitInfo[] { + new UnitInfo(SpeedUnit.CentimeterPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.CentimeterPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.CentimeterPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.DecimeterPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.DecimeterPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.FootPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.FootPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.FootPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.InchPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.InchPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.InchPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.KilometerPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.KilometerPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.KilometerPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.Knot, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MeterPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MeterPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MeterPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MicrometerPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MicrometerPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MilePerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MillimeterPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MillimeterPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.MillimeterPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.NanometerPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.NanometerPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.UsSurveyFootPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.UsSurveyFootPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.UsSurveyFootPerSecond, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.YardPerHour, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.YardPerMinute, BaseUnits.Undefined), + new UnitInfo(SpeedUnit.YardPerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +101,22 @@ public Speed(double numericValue, SpeedUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Speed(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs index 5d1b8c5e46..78e56270b1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs @@ -47,7 +47,19 @@ public partial struct Temperature : IQuantity, IEquatable(QuantityType.Temperature, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Temperature, + new UnitInfo[] { + new UnitInfo(TemperatureUnit.DegreeCelsius, new BaseUnits(temperature: TemperatureUnit.DegreeCelsius)), + new UnitInfo(TemperatureUnit.DegreeDelisle, new BaseUnits(temperature: TemperatureUnit.DegreeDelisle)), + new UnitInfo(TemperatureUnit.DegreeFahrenheit, new BaseUnits(temperature: TemperatureUnit.DegreeFahrenheit)), + new UnitInfo(TemperatureUnit.DegreeNewton, new BaseUnits(temperature: TemperatureUnit.DegreeNewton)), + new UnitInfo(TemperatureUnit.DegreeRankine, new BaseUnits(temperature: TemperatureUnit.DegreeRankine)), + new UnitInfo(TemperatureUnit.DegreeReaumur, new BaseUnits(temperature: TemperatureUnit.DegreeReaumur)), + new UnitInfo(TemperatureUnit.DegreeRoemer, new BaseUnits(temperature: TemperatureUnit.DegreeRoemer)), + new UnitInfo(TemperatureUnit.Kelvin, new BaseUnits(temperature: TemperatureUnit.Kelvin)), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +77,22 @@ public Temperature(double numericValue, TemperatureUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Temperature(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs index 4e73d5f4ef..595955c060 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs @@ -47,7 +47,21 @@ public partial struct TemperatureChangeRate : IQuantity(QuantityType.TemperatureChangeRate, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.TemperatureChangeRate, + new UnitInfo[] { + new UnitInfo(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, BaseUnits.Undefined), + new UnitInfo(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +79,22 @@ public TemperatureChangeRate(double numericValue, TemperatureChangeRateUnit unit _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public TemperatureChangeRate(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs index 1266c9a628..a5f23d26e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs @@ -47,7 +47,19 @@ public partial struct TemperatureDelta : IQuantity, IEquat static TemperatureDelta() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.TemperatureDelta, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.TemperatureDelta, + new UnitInfo[] { + new UnitInfo(TemperatureDeltaUnit.DegreeCelsius, BaseUnits.Undefined), + new UnitInfo(TemperatureDeltaUnit.DegreeDelisle, BaseUnits.Undefined), + new UnitInfo(TemperatureDeltaUnit.DegreeFahrenheit, BaseUnits.Undefined), + new UnitInfo(TemperatureDeltaUnit.DegreeNewton, BaseUnits.Undefined), + new UnitInfo(TemperatureDeltaUnit.DegreeRankine, BaseUnits.Undefined), + new UnitInfo(TemperatureDeltaUnit.DegreeReaumur, BaseUnits.Undefined), + new UnitInfo(TemperatureDeltaUnit.DegreeRoemer, BaseUnits.Undefined), + new UnitInfo(TemperatureDeltaUnit.Kelvin, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +77,22 @@ public TemperatureDelta(double numericValue, TemperatureDeltaUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public TemperatureDelta(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs index 1235416884..bf04c98880 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs @@ -50,7 +50,13 @@ public partial struct ThermalConductivity : IQuantity, static ThermalConductivity() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.ThermalConductivity, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ThermalConductivity, + new UnitInfo[] { + new UnitInfo(ThermalConductivityUnit.BtuPerHourFootFahrenheit, BaseUnits.Undefined), + new UnitInfo(ThermalConductivityUnit.WattPerMeterKelvin, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -68,6 +74,22 @@ public ThermalConductivity(double numericValue, ThermalConductivityUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ThermalConductivity(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs index ddd0a3ed0f..a99aeee888 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs @@ -47,7 +47,16 @@ public partial struct ThermalResistance : IQuantity, IEqu static ThermalResistance() { BaseDimensions = new BaseDimensions(0, -1, 3, 0, 1, 0, 0); - Info = new QuantityInfo(QuantityType.ThermalResistance, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.ThermalResistance, + new UnitInfo[] { + new UnitInfo(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, BaseUnits.Undefined), + new UnitInfo(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, BaseUnits.Undefined), + new UnitInfo(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, BaseUnits.Undefined), + new UnitInfo(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, BaseUnits.Undefined), + new UnitInfo(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +74,22 @@ public ThermalResistance(double numericValue, ThermalResistanceUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public ThermalResistance(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs index 46b530879e..4cf62e39ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs @@ -47,7 +47,32 @@ public partial struct Torque : IQuantity, IEquatable, ICompa static Torque() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Torque, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Torque, + new UnitInfo[] { + new UnitInfo(TorqueUnit.KilogramForceCentimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.KilogramForceMeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.KilogramForceMillimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.KilonewtonCentimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.KilonewtonMeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.KilonewtonMillimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.KilopoundForceFoot, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.KilopoundForceInch, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.MeganewtonCentimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.MeganewtonMeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.MeganewtonMillimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.MegapoundForceFoot, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.MegapoundForceInch, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.NewtonCentimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.NewtonMeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.NewtonMillimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.PoundForceFoot, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.PoundForceInch, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.TonneForceCentimeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.TonneForceMeter, BaseUnits.Undefined), + new UnitInfo(TorqueUnit.TonneForceMillimeter, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +90,22 @@ public Torque(double numericValue, TorqueUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Torque(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs index 22a511ef67..5e9c983911 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs @@ -47,7 +47,12 @@ public partial struct VitaminA : IQuantity, IEquatable, static VitaminA() { BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.VitaminA, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.VitaminA, + new UnitInfo[] { + new UnitInfo(VitaminAUnit.InternationalUnit, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +70,22 @@ public VitaminA(double numericValue, VitaminAUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public VitaminA(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs index 9fee0032c1..cab22ff7e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs @@ -47,7 +47,56 @@ public partial struct Volume : IQuantity, IEquatable, ICompa static Volume() { BaseDimensions = new BaseDimensions(3, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Volume, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.Volume, + new UnitInfo[] { + new UnitInfo(VolumeUnit.AcreFoot, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.AuTablespoon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Centiliter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicCentimeter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicDecimeter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicFoot, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicInch, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicKilometer, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicMeter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicMicrometer, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicMile, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicMillimeter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.CubicYard, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Deciliter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.HectocubicFoot, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.HectocubicMeter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Hectoliter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.ImperialBeerBarrel, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.ImperialGallon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.ImperialOunce, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.KilocubicFoot, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.KilocubicMeter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.KiloimperialGallon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Kiloliter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.KilousGallon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Liter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.MegacubicFoot, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.MegaimperialGallon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Megaliter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.MegausGallon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.MetricCup, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.MetricTeaspoon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Microliter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.Milliliter, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.OilBarrel, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UkTablespoon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsBeerBarrel, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsCustomaryCup, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsGallon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsLegalCup, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsOunce, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsPint, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsQuart, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsTablespoon, BaseUnits.Undefined), + new UnitInfo(VolumeUnit.UsTeaspoon, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +114,22 @@ public Volume(double numericValue, VolumeUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public Volume(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs index 8319eafe8f..bfaf537f65 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs @@ -47,7 +47,59 @@ public partial struct VolumeFlow : IQuantity, IEquatable(QuantityType.VolumeFlow, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo(QuantityType.VolumeFlow, + new UnitInfo[] { + new UnitInfo(VolumeFlowUnit.AcreFootPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.AcreFootPerHour, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.AcreFootPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.AcreFootPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CentiliterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CentiliterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicDecimeterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicFootPerHour, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicFootPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicFootPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicMeterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicMeterPerHour, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicMeterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicMeterPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicMillimeterPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicYardPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicYardPerHour, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicYardPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.CubicYardPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.DeciliterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.DeciliterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.KiloliterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.KiloliterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.KilousGallonPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.LiterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.LiterPerHour, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.LiterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.LiterPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MegaliterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MegaukGallonPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MicroliterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MicroliterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MilliliterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MilliliterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MillionUsGallonsPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.NanoliterPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.NanoliterPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.OilBarrelPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.OilBarrelPerHour, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.OilBarrelPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.OilBarrelPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.UkGallonPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.UkGallonPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.UkGallonPerSecond, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.UsGallonPerDay, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.UsGallonPerHour, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.UsGallonPerMinute, BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.UsGallonPerSecond, BaseUnits.Undefined), + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -65,6 +117,22 @@ public VolumeFlow(double numericValue, VolumeFlowUnit unit) _unit = unit; } + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public VolumeFlow(double numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } + #region Static Properties /// diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index 73d441daf0..ef6c008e56 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -33,32 +33,34 @@ public class QuantityInfo /// Constructs an instance. /// /// The quantity enum value. - /// The list of unit enum values. + /// The information about the units for this quantity. /// The base unit enum value. /// The zero quantity. /// The base dimensions of the quantity. /// Quantity type can not be undefined. /// If units -or- baseUnit -or- zero -or- baseDimensions is null. - public QuantityInfo(QuantityType quantityType, [NotNull] Enum[] units, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions) + public QuantityInfo(QuantityType quantityType, [NotNull] UnitInfo[] unitInfos, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions) { if(quantityType == QuantityType.Undefined) throw new ArgumentException("Quantity type can not be undefined.", nameof(quantityType)); - if(units == null) throw new ArgumentNullException(nameof(units)); if(baseUnit == null) throw new ArgumentNullException(nameof(baseUnit)); BaseDimensions = baseDimensions ?? throw new ArgumentNullException(nameof(baseDimensions)); Zero = zero ?? throw new ArgumentNullException(nameof(zero)); + Name = quantityType.ToString(); QuantityType = quantityType; UnitType = UnitEnumTypes.First(t => t.Name == $"{quantityType}Unit"); - UnitInfos = units.Select(unit => new UnitInfo(unit)).ToArray(); - BaseUnitInfo = new UnitInfo(baseUnit); + UnitInfos = unitInfos ?? throw new ArgumentNullException(nameof(unitInfos)); + BaseUnitInfo = UnitInfos.First(unitInfo => unitInfo.Value.Equals(baseUnit)); + Zero = zero ?? throw new ArgumentNullException(nameof(zero)); ValueType = zero.GetType(); + BaseDimensions = baseDimensions ?? throw new ArgumentNullException(nameof(baseDimensions)); - // Ignore warning about populating obsolete types/members until they are removed + // Obsolete members #pragma warning disable 618 - UnitNames = UnitInfos.Select(unitInfo => unitInfo.Name).ToArray(); - Units = units; + UnitNames = UnitInfos.Select( unitInfo => unitInfo.Name ).ToArray(); + Units = UnitInfos.Select( unitInfo => unitInfo.Value ).ToArray(); BaseUnit = BaseUnitInfo.Value; #pragma warning restore 618 } @@ -121,6 +123,34 @@ public QuantityInfo(QuantityType quantityType, [NotNull] Enum[] units, [NotNull] /// The for a quantity. /// public BaseDimensions BaseDimensions { get; } + + /// + /// Gets the which has that are a subset of the given . + /// + /// The to check against. + /// The UnitInfo that has BaseUnits that are a subset. + /// The baseUnits parameter is null. + /// No unit was found that is a subset of the given BaseUnits. + /// More than one unit was found that is a subset of the given BaseUnits. + public UnitInfo GetUnitInfoFor(BaseUnits baseUnits) + { + if(baseUnits == null) + throw new ArgumentNullException(nameof(baseUnits)); + + var matchingUnitInfos = UnitInfos + .Where((unitInfo) => unitInfo.BaseUnits.IsSubsetOf(baseUnits)) + .Take(2) + .ToArray(); + + var firstUnitInfo = matchingUnitInfos.FirstOrDefault(); + if (firstUnitInfo == null) + throw new InvalidOperationException("No unit was found that is a subset of the given BaseUnits."); + + if (matchingUnitInfos.Length > 1) + throw new InvalidOperationException("More than one unit was found that is a subset of the given BaseUnits."); + + return firstUnitInfo; + } } /// @@ -134,16 +164,16 @@ public class QuantityInfo : QuantityInfo where TUnit : Enum { /// - public QuantityInfo(QuantityType quantityType, TUnit[] units, TUnit baseUnit, IQuantity zero, BaseDimensions baseDimensions) - : base(quantityType, units.Cast().ToArray(), baseUnit, zero, baseDimensions) + public QuantityInfo(QuantityType quantityType, UnitInfo[] unitInfos, TUnit baseUnit, IQuantity zero, BaseDimensions baseDimensions) + : base(quantityType, unitInfos, baseUnit, zero, baseDimensions) { Zero = zero; - UnitInfos = units.Select(unit => new UnitInfo(unit)).ToArray(); - BaseUnitInfo = new UnitInfo(baseUnit); + UnitInfos = unitInfos ?? throw new ArgumentNullException(nameof(unitInfos)); + BaseUnitInfo = UnitInfos.First(unitInfo => unitInfo.Value.Equals(baseUnit)); - // Ignore warning about populating obsolete types/members until they are removed + // Obsolete members #pragma warning disable 618 - Units = units; + Units = UnitInfos.Select( unitInfo => unitInfo.Value ).ToArray(); BaseUnit = BaseUnitInfo.Value; #pragma warning restore 618 } @@ -167,5 +197,11 @@ public QuantityInfo(QuantityType quantityType, TUnit[] units, TUnit baseUnit, IQ /// public new TUnit UnitType { get; } + + /// + public new UnitInfo GetUnitInfoFor(BaseUnits baseUnits) + { + return (UnitInfo)base.GetUnitInfoFor(baseUnits); + } } } diff --git a/UnitsNet/Scripts/GenerateUnits.ps1 b/UnitsNet/Scripts/GenerateUnits.ps1 index 8cd15fe397..a44f6052e6 100644 --- a/UnitsNet/Scripts/GenerateUnits.ps1 +++ b/UnitsNet/Scripts/GenerateUnits.ps1 @@ -16,6 +16,10 @@ function ValueOrDefault($value, $defaultValue){ if ($null -ne $value) { $value } else { $defaultValue } } +function Ternary($value, $one, $two){ + if ($value -ne $null) { $one } else { $two } +} + function GenerateQuantity([Quantity]$quantity, $outDir) { $outFileName = "$outDir/$($quantity.Name).NetFramework.g.cs" @@ -189,6 +193,7 @@ function Add-PrefixUnits { $prefixUnit = New-Object PsObject -Property @{ SingularName=$prefix + $(ToCamelCase $unit.SingularName) PluralName=$prefix + $(ToCamelCase $unit.PluralName) + BaseUnits = $null FromUnitToBaseFunc="("+$unit.FromUnitToBaseFunc+") * $prefixFactor" FromBaseToUnitFunc="("+$unit.FromBaseToUnitFunc+") / $prefixFactor" @@ -283,6 +288,16 @@ $quantities = Get-ChildItem -Path $templatesDir -filter "*.json" ` [Unit]@{ SingularName = $_.SingularName PluralName = $_.PluralName + BaseUnits = Ternary $_.BaseUnits @{ + # $_ | fl | out-string | Write-Host -ForegroundColor green + Length = Ternary $_.BaseUnits.L "length: LengthUnit.$($_.BaseUnits.L)" $null + Mass = Ternary $_.BaseUnits.M "mass: MassUnit.$($_.BaseUnits.M)" $null + Time = Ternary $_.BaseUnits.T "time: DurationUnit.$($_.BaseUnits.T)" $null + ElectricCurrent = Ternary $_.BaseUnits.I "current: ElectricCurrentUnit.$($_.BaseUnits.I)" $null + Temperature = Ternary $_.BaseUnits.Θ "temperature: TemperatureUnit.$($_.BaseUnits.Θ)" $null + AmountOfSubstance = Ternary $_.BaseUnits.N "amount: AmountOfSubstanceUnit.$($_.BaseUnits.N)" $null + LuminousIntensity = Ternary $_.BaseUnits.J "luminousIntensity: LuminousIntensityUnit.$($_.BaseUnits.J)" $null + } $null XmlDocSummary = $_.XmlDocSummary XmlDocRemarks = $_.XmlDocRemarks FromUnitToBaseFunc = $_.FromUnitToBaseFunc diff --git a/UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1 b/UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1 index 35837eef97..bea5b9c73c 100644 --- a/UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1 +++ b/UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1 @@ -85,7 +85,21 @@ if ($obsoleteAttribute) "@; } else {@" BaseDimensions = new BaseDimensions($($baseDimensions.Length), $($baseDimensions.Mass), $($baseDimensions.Time), $($baseDimensions.ElectricCurrent), $($baseDimensions.Temperature), $($baseDimensions.AmountOfSubstance), $($baseDimensions.LuminousIntensity)); "@; }@" - Info = new QuantityInfo<$unitEnumName>(QuantityType.$quantityName, Units, BaseUnit, Zero, BaseDimensions); + + Info = new QuantityInfo<$unitEnumName>(QuantityType.$quantityName, + new UnitInfo<$unitEnumName>[] { +"@; foreach ($unit in $units) { + if($unit.BaseUnits -eq $null){@" + new UnitInfo<$unitEnumName>($unitEnumName.$($unit.SingularName), BaseUnits.Undefined), +"@; } else{ + $baseUnitsArray = @($unit.BaseUnits.Length, $unit.BaseUnits.Mass, $unit.BaseUnits.Time, $unit.BaseUnits.ElectricCurrent, $unit.BaseUnits.Temperature, $unit.BaseUnits.AmountOfSubstance, $unit.BaseUnits.LuminousIntensity) + $baseUnitsArrayFiltered = $baseUnitsArray | Where-Object {$_ -ne ""} + $baseUnitsConstructorString = $baseUnitsArrayFiltered -join ', ';@" + new UnitInfo<$unitEnumName>($unitEnumName.$($unit.SingularName), new BaseUnits($baseUnitsConstructorString)), +"@; } + }@" + }, + BaseUnit, Zero, BaseDimensions); } /// @@ -106,6 +120,26 @@ if ($obsoleteAttribute) "@; }@" _unit = unit; } + + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// + /// The numeric value to contruct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + /// More than one unit was found for the given . + public $quantityName($valueType numericValue, UnitSystem unitSystem) + { + if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem)); + +"@; if ($quantity.BaseType -eq "double") {@" + _value = Guard.EnsureValidNumber(numericValue, nameof(numericValue)); +"@; } else {@" + _value = numericValue; +"@; }@" + _unit = Info.GetUnitInfoFor(unitSystem.BaseUnits).Value; + } "@; GenerateStaticProperties $genArgs GenerateProperties $genArgs diff --git a/UnitsNet/Scripts/Types.psm1 b/UnitsNet/Scripts/Types.psm1 index 8badec4b31..c314e7e866 100644 --- a/UnitsNet/Scripts/Types.psm1 +++ b/UnitsNet/Scripts/Types.psm1 @@ -1,4 +1,4 @@ -class Quantity +class Quantity { [string]$Name [string]$XmlDocSummary @@ -18,12 +18,24 @@ class Unit [string]$PluralName [string]$XmlDocSummary [string]$XmlDocRemarks + [BaseUnits]$BaseUnits [string]$FromUnitToBaseFunc [string]$FromBaseToUnitFunc [string[]]$Prefixes = @() [Localization[]]$Localization = @() } +class BaseUnits +{ + [string]$Length + [string]$Mass + [string]$Time + [string]$ElectricCurrent + [string]$Temperature + [string]$AmountOfSubstance + [string]$LuminousIntensity +} + class Localization { [string]$Culture diff --git a/UnitsNet/UnitInfo.cs b/UnitsNet/UnitInfo.cs index e70d6638b9..7f44311779 100644 --- a/UnitsNet/UnitInfo.cs +++ b/UnitsNet/UnitInfo.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using JetBrains.Annotations; using UnitsNet.Units; namespace UnitsNet @@ -17,13 +18,16 @@ namespace UnitsNet /// public class UnitInfo { - /// Creates an instance from a unit enum value. - /// The unit enum value. - /// new UnitInfo(LengthUnit.Meter) - public UnitInfo(Enum value) + /// + /// Creates an instance of the UnitInfo class. + /// + /// The enum value for this class, for example . + /// The for this unit. + public UnitInfo([NotNull] Enum value, [NotNull] BaseUnits baseUnits) { - Value = value; + Value = value ?? throw new ArgumentNullException(nameof(value)); Name = value.ToString(); + BaseUnits = baseUnits ?? throw new ArgumentNullException(nameof(baseUnits)); } /// @@ -36,6 +40,11 @@ public UnitInfo(Enum value) /// The name of the unit, such as ["Centimeter", "Decimeter", "Meter", ...]. /// public string Name { get; } + + /// + /// Gets the for this unit. + /// + public BaseUnits BaseUnits { get; } } /// @@ -49,7 +58,7 @@ public class UnitInfo : UnitInfo where TUnit : Enum { /// - public UnitInfo(TUnit value) : base(value) + public UnitInfo(TUnit value, BaseUnits baseUnits) : base(value, baseUnits) { Value = value; }