From d93e058d0170dc0ea3fbf6fe55fd2a8b90d3e610 Mon Sep 17 00:00:00 2001 From: Muximize Date: Thu, 9 Nov 2023 01:19:23 +0100 Subject: [PATCH 01/12] Define unit relations --- Common/UnitRelations.json | 164 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 Common/UnitRelations.json diff --git a/Common/UnitRelations.json b/Common/UnitRelations.json new file mode 100644 index 0000000000..622b3a21e8 --- /dev/null +++ b/Common/UnitRelations.json @@ -0,0 +1,164 @@ +[ + "Acceleration.MeterPerSecondSquared = Force.Newton / Mass.Kilogram", + "Acceleration.MeterPerSecondSquared = SpecificWeight.NewtonPerCubicMeter / Density.KilogramPerCubicMeter", + "Acceleration.MeterPerSecondSquared = Speed.MeterPerSecond / Duration.Second", + "AmountOfSubstance.Kilomole = MolarFlow.KilomolePerSecond * Duration.Second", + "AmountOfSubstance.Mole = Mass.Kilogram / MolarMass.KilogramPerMole", + "Angle.Radian = RotationalSpeed.RadianPerSecond * Duration.Second", + "Angle.Radian = Torque.NewtonMeter / RotationalStiffness.NewtonMeterPerRadian", + "Area.SquareMeter = KinematicViscosity.SquareMeterPerSecond * Duration.Second", + "Area.SquareMeter = Length.Meter * Length.Meter", + "Area.SquareMeter = LinearDensity.KilogramPerMeter / Density.KilogramPerCubicMeter", + "Area.SquareMeter = LuminousIntensity.Candela / Luminance.CandelaPerSquareMeter", + "Area.SquareMeter = Mass.Kilogram / AreaDensity.KilogramPerSquareMeter", + "Area.SquareMeter = MassFlow.KilogramPerSecond / MassFlux.KilogramPerSecondPerSquareMeter", + "Area.SquareMeter = Power.Watt / HeatFlux.WattPerSquareMeter", + "Area.SquareMeter = Volume.CubicMeter / Length.Meter", + "Area.SquareMeter = VolumeFlow.CubicMeterPerSecond / Speed.MeterPerSecond", + "AreaDensity.KilogramPerSquareMeter = Mass.Kilogram / Area.SquareMeter", + "BrakeSpecificFuelConsumption.KilogramPerJoule = double / SpecificEnergy.JoulePerKilogram", + "BrakeSpecificFuelConsumption.KilogramPerJoule = MassFlow.KilogramPerSecond / Power.Watt", + "Density.KilogramPerCubicMeter = double / SpecificVolume.CubicMeterPerKilogram", + "Density.KilogramPerCubicMeter = LinearDensity.KilogramPerMeter / Area.SquareMeter", + "Density.KilogramPerCubicMeter = Mass.Kilogram / Volume.CubicMeter", + "Density.KilogramPerCubicMeter = MassFlow.KilogramPerSecond / VolumeFlow.CubicMeterPerSecond", + "Density.KilogramPerCubicMeter = MassFlux.KilogramPerSecondPerSquareMeter / Speed.MeterPerSecond", + "Density.KilogramPerCubicMeter = SpecificWeight.NewtonPerCubicMeter / Acceleration.MeterPerSecondSquared", + "double = SpecificEnergy.JoulePerKilogram * BrakeSpecificFuelConsumption.KilogramPerJoule", + "double = TemperatureDelta.Kelvin * CoefficientOfThermalExpansion.PerKelvin", + "Duration.Hour = ElectricCharge.AmpereHour / ElectricCurrent.Ampere", + "Duration.Second = Energy.Joule / Power.Watt", + "Duration.Second = Force.Newton / ForceChangeRate.NewtonPerSecond", + "Duration.Second = Length.Meter / Speed.MeterPerSecond", + "Duration.Second = Speed.MeterPerSecond / Acceleration.MeterPerSecondSquared", + "DynamicViscosity.NewtonSecondPerMeterSquared = Density.KilogramPerCubicMeter * KinematicViscosity.SquareMeterPerSecond", + "ElectricCharge.AmpereHour = ElectricCurrent.Ampere * Duration.Hour", + "ElectricCharge.Coulomb = Energy.Joule / ElectricPotential.Volt", + "ElectricConductivity.SiemensPerMeter = 1 / ElectricResistivity.OhmMeter", + "ElectricCurrent.Ampere = ElectricCharge.AmpereHour / Duration.Hour", + "ElectricCurrent.Ampere = ElectricCurrentGradient.AmperePerSecond * Duration.Second", + "ElectricCurrent.Ampere = ElectricPotential.Volt / ElectricResistance.Ohm", + "ElectricCurrent.Ampere = Power.Watt / ElectricPotential.Volt", + "ElectricCurrentGradient.AmperePerSecond = ElectricCurrent.Ampere / Duration.Second", + "ElectricPotential.Volt = ElectricCurrent.Ampere * ElectricResistance.Ohm", + "ElectricPotential.Volt = Energy.Joule / ElectricCharge.Coulomb", + "ElectricPotential.Volt = Power.Watt / ElectricCurrent.Ampere", + "ElectricResistance.Ohm = ElectricPotential.Volt / ElectricCurrent.Ampere", + "Energy.Joule = ElectricPotential.Volt * ElectricCharge.Coulomb", + "Energy.Joule = EnergyDensity.JoulePerCubicMeter * Volume.CubicMeter", + "Energy.Joule = Power.Watt * Duration.Second", + "Energy.Joule = SpecificEnergy.JoulePerKilogram * Mass.Kilogram", + "Energy.Joule = TemperatureDelta.Kelvin * Entropy.JoulePerKelvin", + "Entropy.JoulePerKelvin = Energy.Joule / TemperatureDelta.Kelvin", + "Entropy.JoulePerKelvin = SpecificEntropy.JoulePerKilogramKelvin * Mass.Kilogram", + "Force.Newton = ForceChangeRate.NewtonPerSecond * Duration.Second", + "Force.Newton = ForcePerLength.NewtonPerMeter * Length.Meter", + "Force.Newton = ForcePerLength.NewtonPerMeter / ReciprocalLength.InverseMeter", + "Force.Newton = Mass.Kilogram * Acceleration.MeterPerSecondSquared", + "Force.Newton = Power.Watt / Speed.MeterPerSecond", + "Force.Newton = Pressure.Pascal * Area.SquareMeter", + "Force.Newton = Pressure.Pascal / ReciprocalArea.InverseSquareMeter", + "Force.Newton = Torque.NewtonMeter / Length.Meter", + "ForcePerLength.NewtonPerMeter = Force.Newton * ReciprocalLength.InverseMeter", + "ForcePerLength.NewtonPerMeter = Force.Newton / Length.Meter", + "ForcePerLength.NewtonPerMeter = Pressure.Pascal / ReciprocalLength.InverseMeter", + "ForcePerLength.NewtonPerMeter = SpecificWeight.NewtonPerCubicMeter * Area.SquareMeter", + "HeatFlux.WattPerSquareMeter = Power.Watt / Area.SquareMeter", + "Jerk.MeterPerSecondCubed = Acceleration.MeterPerSecondSquared / Duration.Second", + "KinematicViscosity.SquareMeterPerSecond = DynamicViscosity.NewtonSecondPerMeterSquared / Density.KilogramPerCubicMeter", + "KinematicViscosity.SquareMeterPerSecond = Length.Meter * Speed.MeterPerSecond", + "Length.Kilometer = TemperatureDelta.Kelvin / TemperatureGradient.DegreeCelsiusPerKilometer", + "Length.Meter = Area.SquareMeter / Length.Meter", + "Length.Meter = Force.Newton / ForcePerLength.NewtonPerMeter", + "Length.Meter = Mass.Kilogram / LinearDensity.KilogramPerMeter", + "Length.Meter = Pressure.Pascal / SpecificWeight.NewtonPerCubicMeter", + "Length.Meter = ReciprocalLength.InverseMeter / ReciprocalArea.InverseSquareMeter", + "Length.Meter = RotationalStiffness.NewtonMeterPerRadian / RotationalStiffnessPerLength.NewtonMeterPerRadianPerMeter", + "Length.Meter = Speed.MeterPerSecond * Duration.Second", + "Length.Meter = Torque.NewtonMeter / Force.Newton", + "Length.Meter = Volume.CubicMeter / Area.SquareMeter", + "LinearDensity.KilogramPerMeter = Area.SquareMeter * Density.KilogramPerCubicMeter", + "LinearDensity.KilogramPerMeter = Mass.Kilogram / Length.Meter", + "Luminance.CandelaPerSquareMeter = LuminousIntensity.Candela / Area.SquareMeter", + "LuminousIntensity.Candela = Luminance.CandelaPerSquareMeter * Area.SquareMeter", + "Mass.Gram = AmountOfSubstance.Mole * MolarMass.GramPerMole", + "Mass.Kilogram = AreaDensity.KilogramPerSquareMeter * Area.SquareMeter", + "Mass.Kilogram = Density.KilogramPerCubicMeter * Volume.CubicMeter", + "Mass.Kilogram = Energy.Joule / SpecificEnergy.JoulePerKilogram", + "Mass.Kilogram = Force.Newton / Acceleration.MeterPerSecondSquared", + "Mass.Kilogram = LinearDensity.KilogramPerMeter * Length.Meter", + "Mass.Kilogram = Mass.Kilogram / MassFraction.DecimalFraction", + "Mass.Kilogram = MassConcentration.KilogramPerCubicMeter * Volume.CubicMeter", + "Mass.Kilogram = MassFlow.KilogramPerSecond * Duration.Second", + "Mass.Kilogram = MassFraction.DecimalFraction * Mass.Kilogram", + "MassConcentration.GramPerCubicMeter = Molarity.MolePerCubicMeter * MolarMass.GramPerMole", + "MassConcentration.KilogramPerCubicMeter = VolumeConcentration.DecimalFraction * Density.KilogramPerCubicMeter", + "MassFlow.GramPerSecond = Area.SquareMeter * MassFlux.GramPerSecondPerSquareMeter", + "MassFlow.KilogramPerSecond = Mass.Kilogram / Duration.Second", + "MassFlow.KilogramPerSecond = MolarFlow.KilomolePerSecond * MolarMass.KilogramPerKilomole", + "MassFlow.KilogramPerSecond = Power.Watt * BrakeSpecificFuelConsumption.KilogramPerJoule", + "MassFlow.KilogramPerSecond = Power.Watt / SpecificEnergy.JoulePerKilogram", + "MassFlow.KilogramPerSecond = VolumeFlow.CubicMeterPerSecond * Density.KilogramPerCubicMeter", + "MassFlux.KilogramPerSecondPerSquareMeter = MassFlow.KilogramPerSecond / Area.SquareMeter", + "MassFlux.KilogramPerSecondPerSquareMeter = Speed.MeterPerSecond * Density.KilogramPerCubicMeter", + "Molarity.MolePerCubicMeter = AmountOfSubstance.Mole / Volume.CubicMeter", + "Molarity.MolePerCubicMeter = MassConcentration.GramPerCubicMeter / MolarMass.GramPerMole", + "Molarity.MolePerCubicMeter = Molarity.MolePerCubicMeter * VolumeConcentration.DecimalFraction", + "Power.Watt = ElectricPotential.Volt * ElectricCurrent.Ampere", + "Power.Watt = Energy.Joule * Frequency.PerSecond", + "Power.Watt = Energy.Joule / Duration.Second", + "Power.Watt = Force.Newton * Speed.MeterPerSecond", + "Power.Watt = HeatFlux.WattPerSquareMeter * Area.SquareMeter", + "Power.Watt = MassFlow.KilogramPerSecond / BrakeSpecificFuelConsumption.KilogramPerJoule", + "Power.Watt = SpecificEnergy.JoulePerKilogram * MassFlow.KilogramPerSecond", + "Pressure.NewtonPerSquareMeter = Force.Newton * ReciprocalArea.InverseSquareMeter", + "Pressure.NewtonPerSquareMeter = ForcePerLength.NewtonPerMeter * ReciprocalLength.InverseMeter", + "Pressure.NewtonPerSquareMeter = ForcePerLength.NewtonPerMeter / Length.Meter", + "Pressure.Pascal = Force.Newton / Area.SquareMeter", + "Pressure.Pascal = PressureChangeRate.PascalPerSecond * Duration.Second", + "Pressure.Pascal = SpecificWeight.NewtonPerCubicMeter * Length.Meter", + "PressureChangeRate.PascalPerSecond = Pressure.Pascal / Duration.Second", + "Ratio.DecimalFraction = Area.SquareMeter * ReciprocalArea.InverseSquareMeter", + "ReciprocalArea.InverseSquareMeter = 1 / Area.SquareMeter", + "ReciprocalArea.InverseSquareMeter = ReciprocalLength.InverseMeter * ReciprocalLength.InverseMeter", + "ReciprocalLength.InverseMeter = 1 / Length.Meter", + "ReciprocalLength.InverseMeter = ReciprocalArea.InverseSquareMeter / ReciprocalLength.InverseMeter", + "RotationalSpeed.RadianPerSecond = Angle.Radian / Duration.Second", + "RotationalSpeed.RadianPerSecond = Power.Watt / Torque.NewtonMeter", + "RotationalStiffness.NewtonMeterPerRadian = RotationalStiffnessPerLength.NewtonMeterPerRadianPerMeter * Length.Meter", + "RotationalStiffness.NewtonMeterPerRadian = Torque.NewtonMeter / Angle.Radian", + "RotationalStiffnessPerLength.NewtonMeterPerRadianPerMeter = RotationalStiffness.NewtonMeterPerRadian / Length.Meter", + "SpecificEnergy.JoulePerKilogram = double / BrakeSpecificFuelConsumption.KilogramPerJoule", + "SpecificEnergy.JoulePerKilogram = Energy.Joule / Mass.Kilogram", + "SpecificEnergy.JoulePerKilogram = Power.Watt / MassFlow.KilogramPerSecond", + "SpecificEnergy.JoulePerKilogram = SpecificEntropy.JoulePerKilogramKelvin * TemperatureDelta.Kelvin", + "SpecificEnergy.JoulePerKilogram = Speed.MeterPerSecond * Speed.MeterPerSecond", + "SpecificEntropy.JoulePerKilogramKelvin = Entropy.JoulePerKelvin / Mass.Kilogram", + "SpecificEntropy.JoulePerKilogramKelvin = SpecificEnergy.JoulePerKilogram / TemperatureDelta.Kelvin", + "SpecificWeight.NewtonPerCubicMeter = Acceleration.MeterPerSecondSquared * Density.KilogramPerCubicMeter", + "SpecificWeight.NewtonPerCubicMeter = Pressure.Pascal / Length.Meter", + "Speed.MeterPerSecond = Acceleration.MeterPerSecondSquared * Duration.Second", + "Speed.MeterPerSecond = KinematicViscosity.SquareMeterPerSecond / Length.Meter", + "Speed.MeterPerSecond = Length.Meter / Duration.Second", + "Speed.MeterPerSecond = MassFlux.KilogramPerSecondPerSquareMeter / Density.KilogramPerCubicMeter", + "Speed.MeterPerSecond = VolumeFlow.CubicMeterPerSecond / Area.SquareMeter", + "TemperatureDelta.DegreeCelsius = TemperatureChangeRate.DegreeCelsiusPerSecond * Duration.Second", + "TemperatureDelta.DegreeCelsius = TemperatureGradient.DegreeCelsiusPerKilometer * Length.Kilometer", + "TemperatureDelta.Kelvin = Energy.Joule / Entropy.JoulePerKelvin", + "TemperatureGradient.KelvinPerMeter = TemperatureDelta.Kelvin / Length.Meter", + "Torque.NewtonMeter = ForcePerLength.NewtonPerMeter * Area.SquareMeter", + "Torque.NewtonMeter = Length.Meter * Force.Newton", + "Torque.NewtonMeter = Power.Watt / RotationalSpeed.RadianPerSecond", + "Torque.NewtonMeter = RotationalStiffness.NewtonMeterPerRadian * Angle.Radian", + "Volume.CubicMeter = AmountOfSubstance.Mole / Molarity.MolePerCubicMeter", + "Volume.CubicMeter = AreaMomentOfInertia.MeterToTheFourth / Length.Meter", + "Volume.CubicMeter = Length.Meter * Area.SquareMeter", + "Volume.CubicMeter = Mass.Kilogram / Density.KilogramPerCubicMeter", + "Volume.CubicMeter = SpecificVolume.CubicMeterPerKilogram * Mass.Kilogram", + "Volume.CubicMeter = VolumeFlow.CubicMeterPerSecond * Duration.Second", + "VolumeConcentration.DecimalFraction = MassConcentration.KilogramPerCubicMeter / Density.KilogramPerCubicMeter", + "VolumeFlow.CubicMeterPerSecond = Area.SquareMeter * Speed.MeterPerSecond", + "VolumeFlow.CubicMeterPerSecond = MassFlow.KilogramPerSecond / Density.KilogramPerCubicMeter", + "VolumeFlow.CubicMeterPerSecond = MolarFlow.MolePerSecond / Molarity.MolePerCubicMeter", + "VolumeFlow.CubicMeterPerSecond = Volume.CubicMeter / Duration.Second" +] \ No newline at end of file From ce1a6fff8198b170a27348829334f218c32615d8 Mon Sep 17 00:00:00 2001 From: Muximize Date: Mon, 6 Nov 2023 19:09:20 +0100 Subject: [PATCH 02/12] Add relations to CodeGen --- CodeGen/Generators/QuantityRelationsParser.cs | 181 ++++++++++++++++++ .../UnitsNetGen/QuantityGenerator.cs | 128 ++++++++++++- CodeGen/JsonTypes/Quantity.cs | 3 +- CodeGen/JsonTypes/QuantityRelation.cs | 27 +++ CodeGen/JsonTypes/Unit.cs | 2 +- CodeGen/Program.cs | 4 +- 6 files changed, 340 insertions(+), 5 deletions(-) create mode 100644 CodeGen/Generators/QuantityRelationsParser.cs create mode 100644 CodeGen/JsonTypes/QuantityRelation.cs diff --git a/CodeGen/Generators/QuantityRelationsParser.cs b/CodeGen/Generators/QuantityRelationsParser.cs new file mode 100644 index 0000000000..4ec5bb62be --- /dev/null +++ b/CodeGen/Generators/QuantityRelationsParser.cs @@ -0,0 +1,181 @@ +// 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; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CodeGen.JsonTypes; +using Newtonsoft.Json; + +namespace CodeGen.Generators +{ + /// + /// Parses the JSON file that defines the relationships (operators) between quantities + /// and applies them to the parsed quantity objects. + /// + internal static class QuantityRelationsParser + { + /// + /// Parse and apply relations to quantities. + /// Each defined relation can be applied multiple times to one or two quantities depending on the operator and the operands. + /// + /// The format of a relation definition is "Quantity.Unit operator Quantity.Unit = Quantity.Unit". + /// "double" can be used as a unitless operand. + /// "1" can be used as the left operand to define inverse relations. + /// + /// Repository root directory. + /// List of previously parsed Quantity objects. + public static void ParseAndApplyRelations(string rootDir, Quantity[] quantities) + { + var quantityDictionary = quantities.ToDictionary(q => q.Name, q => q); + + // Add double and 1 as pseudo-quantities to validate relations that use them. + var pseudoQuantity = new Quantity { Name = null!, Units = new[] { new Unit { SingularName = null! } } }; + quantityDictionary["double"] = pseudoQuantity with { Name = "double" }; + quantityDictionary["1"] = pseudoQuantity with { Name = "1" }; + + var relations = ParseRelations(rootDir, quantityDictionary); + var timespanRelations = new List(); + + foreach (var relation in relations) + { + if (relation.LeftQuantity.Name == "Duration") + { + timespanRelations.Add(relation with + { + LeftQuantity = new Quantity { Name = "TimeSpan" }, + }); + } + + if (relation.RightQuantity.Name == "Duration") + { + timespanRelations.Add(relation with + { + RightQuantity = new Quantity { Name = "TimeSpan" }, + }); + } + } + + relations.AddRange(timespanRelations); + + foreach (var quantity in quantities) + { + var quantityRelations = new List(); + + foreach (var relation in relations) + { + if (relation.LeftQuantity == quantity) + { + quantityRelations.Add(relation); + if (relation is { Operator: "*", RightQuantity.Name: "TimeSpan" or "double" }) + { + quantityRelations.Add(relation.Swapped()); + } + } + + if (relation.RightQuantity == quantity) + { + if (relation.Operator == "inverse" || relation.Operator == "*" && relation.LeftQuantity != relation.RightQuantity) + { + quantityRelations.Add(relation.Swapped()); + } + + if (relation is { Operator: "/", LeftQuantity.Name: "double" }) + { + quantityRelations.Add(relation); + } + } + } + + quantity.Relations = quantityRelations.ToArray(); + } + } + + private static List ParseRelations(string rootDir, IReadOnlyDictionary quantities) + { + var relationsFileName = Path.Combine(rootDir, "Common/UnitRelations.json"); + + try + { + var text = File.ReadAllText(relationsFileName); + var relationStrings = JsonConvert.DeserializeObject>(text) ?? new List(); + relationStrings.Sort(); + + var parsedRelations = relationStrings.Select(relationString => ParseRelation(relationString, quantities)).ToList(); + + // File parsed successfully, save it back to disk in the sorted state. + File.WriteAllText(relationsFileName, JsonConvert.SerializeObject(relationStrings, Formatting.Indented)); + + return parsedRelations; + } + catch (Exception e) + { + throw new Exception($"Error parsing relations file: {relationsFileName}", e); + } + } + + private static QuantityRelation ParseRelation(string relationString, IReadOnlyDictionary quantities) + { + var segments = relationString.Split(' '); + + if (segments.Length != 5 || segments[1] != "=") + { + throw new Exception($"Invalid relation string: {relationString}"); + } + + var @operator = segments[3]; + var left = segments[2].Split('.'); + var right = segments[4].Split('.'); + var result = segments[0].Split('.'); + + var leftQuantity = GetQuantity(left[0]); + var rightQuantity = GetQuantity(right[0]); + var resultQuantity = GetQuantity(result[0]); + + var leftUnit = GetUnit(leftQuantity, left.ElementAtOrDefault(1)); + var rightUnit = GetUnit(rightQuantity, right.ElementAtOrDefault(1)); + var resultUnit = GetUnit(resultQuantity, result.ElementAtOrDefault(1)); + + if (leftQuantity.Name == "1") + { + @operator = "inverse"; + leftQuantity = resultQuantity; + leftUnit = resultUnit; + } + + return new QuantityRelation + { + Operator = @operator, + LeftQuantity = leftQuantity, + LeftUnit = leftUnit, + RightQuantity = rightQuantity, + RightUnit = rightUnit, + ResultQuantity = resultQuantity, + ResultUnit = resultUnit + }; + + Quantity GetQuantity(string quantityName) + { + if (!quantities.TryGetValue(quantityName, out var quantity)) + { + throw new Exception($"Undefined quantity {quantityName} in relation string: {relationString}"); + } + + return quantity; + } + + Unit GetUnit(Quantity quantity, string? unitName) + { + try + { + return quantity.Units.First(u => u.SingularName == unitName); + } + catch (InvalidOperationException) + { + throw new Exception($"Undefined unit {unitName} in relation string: {relationString}"); + } + } + } + } +} \ No newline at end of file diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 031b5d0c55..9da38e6b23 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -17,6 +17,8 @@ internal class QuantityGenerator : GeneratorBase private readonly string _valueType; private readonly Unit _baseUnit; + private readonly string[] _decimalTypes = { "BitRate", "Information", "Power" }; + public QuantityGenerator(Quantity quantity) { _quantity = quantity ?? throw new ArgumentNullException(nameof(quantity)); @@ -39,8 +41,12 @@ public string Generate() using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; -using System.Linq; -using System.Runtime.Serialization; +using System.Linq;"); + if (_quantity.Relations.Any(r => r.Operator is "*" or "/")) + Writer.WL(@"#if NET7_0_OR_GREATER +using System.Numerics; +#endif"); + Writer.WL(@"using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -67,6 +73,35 @@ namespace UnitsNet public readonly partial struct {_quantity.Name} : {(_quantity.GenerateArithmetic ? "IArithmeticQuantity" : "IQuantity")}<{_quantity.Name}, {_unitEnumName}, {_quantity.ValueType}>,"); + if (_quantity.Relations.Any(r => r.Operator is "*" or "/")) + { + Writer.WL(@$" +#if NET7_0_OR_GREATER"); + foreach (var relation in _quantity.Relations) + { + if (relation.LeftQuantity == _quantity) + { + switch (relation.Operator) + { + case "*": + Writer.W(@" + IMultiplyOperators"); + break; + case "/": + Writer.W(@" + IDivisionOperators"); + break; + default: + continue; + } + Writer.WL($"<{relation.LeftQuantity.Name}, {relation.RightQuantity.Name}, {relation.ResultQuantity.Name}>,"); + } + } + + Writer.WL(@$" +#endif"); + } + if (_quantity.ValueType == "decimal") Writer.WL(@$" IDecimalQuantity,"); @@ -100,6 +135,7 @@ namespace UnitsNet GenerateStaticFactoryMethods(); GenerateStaticParseMethods(); GenerateArithmeticOperators(); + GenerateRelationalOperators(); GenerateEqualityAndComparison(); GenerateConversionMethods(); GenerateToString(); @@ -696,6 +732,94 @@ private void GenerateLogarithmicArithmeticOperators() " ); } + /// + /// Generates operators that express relations between quantities as applied by . + /// + private void GenerateRelationalOperators() + { + if (!_quantity.Relations.Any()) return; + + Writer.WL($@" + #region Relational Operators +"); + + foreach (QuantityRelation relation in _quantity.Relations) + { + if (relation.Operator == "inverse") + { + Writer.WL($@" + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public {relation.RightQuantity.Name} Inverse() + {{ + return {relation.LeftUnit.PluralName} == 0.0 ? {relation.RightQuantity.Name}.Zero : {relation.RightQuantity.Name}.From{relation.RightUnit.PluralName}(1 / {relation.LeftUnit.PluralName}); + }} +"); + } + else + { + var leftParameter = relation.LeftQuantity.Name.ToCamelCase(); + var leftConversionProperty = relation.LeftUnit.PluralName; + var rightParameter = relation.RightQuantity.Name.ToCamelCase(); + var rightConversionProperty = relation.RightUnit.PluralName; + + if (relation.LeftQuantity.Name == "TimeSpan") + { + leftConversionProperty = "Total" + leftConversionProperty; + } + + if (relation.RightQuantity.Name == "TimeSpan") + { + rightConversionProperty = "Total" + rightConversionProperty; + } + + if (leftParameter == rightParameter) + { + leftParameter = "left"; + rightParameter = "right"; + } + + var leftPart = $"{leftParameter}.{leftConversionProperty}"; + var rightPart = $"{rightParameter}.{rightConversionProperty}"; + + if (leftParameter == "double") + { + leftParameter = "value"; + leftPart = "value"; + } + + if (rightParameter == "double") + { + rightParameter = "value"; + rightPart = "value"; + } + + var leftCast = _decimalTypes.Contains(relation.LeftQuantity.Name) ? "(double)" : ""; + var rightCast = _decimalTypes.Contains(relation.RightQuantity.Name) ? "(double)" : ""; + + var expression = $"{leftCast}{leftPart} {relation.Operator} {rightCast}{rightPart}"; + + if (relation.ResultQuantity.Name is not ("double" or "decimal")) + { + expression = $"{relation.ResultQuantity.Name}.From{relation.ResultUnit.PluralName}({expression})"; + } + + Writer.WL($@" + /// Get from {relation.Operator} . + public static {relation.ResultQuantity.Name} operator {relation.Operator}({relation.LeftQuantity.Name} {leftParameter}, {relation.RightQuantity.Name} {rightParameter}) + {{ + return {expression}; + }} +"); + } + } + + Writer.WL($@" + + #endregion +"); + } + private void GenerateEqualityAndComparison() { Writer.WL($@" diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index 4af26113fc..6956560161 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -5,7 +5,7 @@ namespace CodeGen.JsonTypes { - internal class Quantity + internal record Quantity { // 0649 Field is never assigned to #pragma warning disable 0649 @@ -18,6 +18,7 @@ internal class Quantity public int LogarithmicScalingFactor = 1; public string Name = null!; public Unit[] Units = Array.Empty(); + public QuantityRelation[] Relations = Array.Empty(); public string? XmlDocRemarks; public string XmlDocSummary = null!; public string? ObsoleteText; diff --git a/CodeGen/JsonTypes/QuantityRelation.cs b/CodeGen/JsonTypes/QuantityRelation.cs new file mode 100644 index 0000000000..66c6108124 --- /dev/null +++ b/CodeGen/JsonTypes/QuantityRelation.cs @@ -0,0 +1,27 @@ +// 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. + +namespace CodeGen.JsonTypes +{ + internal record QuantityRelation + { + public string Operator = null!; + + public Quantity LeftQuantity = null!; + public Unit LeftUnit = null!; + + public Quantity RightQuantity = null!; + public Unit RightUnit = null!; + + public Quantity ResultQuantity = null!; + public Unit ResultUnit = null!; + + public QuantityRelation Swapped() => this with + { + LeftQuantity = RightQuantity, + LeftUnit = RightUnit, + RightQuantity = LeftQuantity, + RightUnit = LeftUnit, + }; + } +} \ No newline at end of file diff --git a/CodeGen/JsonTypes/Unit.cs b/CodeGen/JsonTypes/Unit.cs index 4a775c08f9..eb6a382a3b 100644 --- a/CodeGen/JsonTypes/Unit.cs +++ b/CodeGen/JsonTypes/Unit.cs @@ -5,7 +5,7 @@ namespace CodeGen.JsonTypes { - internal class Unit + internal record Unit { // 0649 Field is never assigned to #pragma warning disable 0649 diff --git a/CodeGen/Program.cs b/CodeGen/Program.cs index d5589d5d1d..cfeecb0a93 100644 --- a/CodeGen/Program.cs +++ b/CodeGen/Program.cs @@ -65,10 +65,12 @@ public static int Main(bool verbose = false, DirectoryInfo? repositoryRoot = nul if (verbose) Log.Debug("Verbose output enabled"); var sw = Stopwatch.StartNew(); - var quantities = QuantityJsonFilesParser.ParseQuantities(repositoryRoot.FullName); + var quantities = QuantityJsonFilesParser.ParseQuantities(rootDir); QuantityNameToUnitEnumValues quantityNameToUnitEnumValues = UnitEnumValueAllocator.AllocateNewUnitEnumValues($"{rootDir}/Common/UnitEnumValues.g.json", quantities); + QuantityRelationsParser.ParseAndApplyRelations(rootDir, quantities); + UnitsNetGenerator.Generate(rootDir, quantities, quantityNameToUnitEnumValues); if (updateNanoFrameworkDependencies) From cfefd260370de1e6aaad7d93ebaef8760eec5b0f Mon Sep 17 00:00:00 2001 From: Muximize Date: Mon, 6 Nov 2023 22:57:47 +0100 Subject: [PATCH 03/12] Generate code, clean up extras --- .../Quantities/Acceleration.extra.cs | 32 ----- .../Quantities/AmountOfSubstance.extra.cs | 25 ---- UnitsNet/CustomCode/Quantities/Angle.extra.cs | 22 ---- UnitsNet/CustomCode/Quantities/Area.extra.cs | 42 ------- .../Quantities/AreaDensity.extra.cs | 14 --- .../Quantities/AreaMomentOfInertia.extra.cs | 14 --- .../BrakeSpecificFuelConsumption.extra.cs | 26 ---- .../CoefficientOfThermalExpansion.extra.cs | 11 -- .../CustomCode/Quantities/Density.extra.cs | 46 ------- .../CustomCode/Quantities/Duration.extra.cs | 24 ---- .../Quantities/DynamicViscosity.extra.cs | 14 --- .../Quantities/ElectricCharge.extra.cs | 26 ---- .../Quantities/ElectricConductivity.extra.cs | 22 ---- .../Quantities/ElectricCurrent.extra.cs | 42 ------- .../ElectricCurrentGradient.extra.cs | 22 ---- .../Quantities/ElectricPotential.extra.cs | 27 ----- .../Quantities/ElectricResistance.extra.cs | 15 --- .../Quantities/ElectricResistivity.extra.cs | 22 ---- .../CustomCode/Quantities/Energy.extra.cs | 76 ------------ .../Quantities/EnergyDensity.extra.cs | 16 --- .../CustomCode/Quantities/Entropy.extra.cs | 14 --- UnitsNet/CustomCode/Quantities/Force.extra.cs | 54 --------- .../Quantities/ForceChangeRate.extra.cs | 16 --- .../Quantities/ForcePerLength.extra.cs | 44 ------- .../CustomCode/Quantities/HeatFlux.extra.cs | 14 --- .../Quantities/KinematicViscosity.extra.cs | 46 ------- .../CustomCode/Quantities/Length.extra.cs | 71 ----------- .../Quantities/LinearDensity.extra.cs | 27 ----- .../CustomCode/Quantities/Luminance.extra.cs | 14 --- .../Quantities/LuminousIntensity.extra.cs | 20 --- UnitsNet/CustomCode/Quantities/Mass.extra.cs | 66 ---------- .../Quantities/MassConcentration.extra.cs | 29 ----- .../CustomCode/Quantities/MassFlow.extra.cs | 76 ------------ .../CustomCode/Quantities/MassFlux.extra.cs | 26 ---- .../Quantities/MassFraction.extra.cs | 18 --- .../CustomCode/Quantities/MolarFlow.extra.cs | 32 ----- .../CustomCode/Quantities/Molarity.extra.cs | 29 ----- UnitsNet/CustomCode/Quantities/Power.extra.cs | 86 ------------- .../CustomCode/Quantities/Pressure.extra.cs | 58 --------- .../Quantities/PressureChangeRate.extra.cs | 22 ---- .../Quantities/ReciprocalArea.extra.cs | 40 ------ .../Quantities/ReciprocalLength.extra.cs | 46 ------- .../Quantities/RotationalSpeed.extra.cs | 34 ------ .../Quantities/RotationalStiffness.extra.cs | 26 ---- .../RotationalStiffnessPerLength.extra.cs | 15 --- .../Quantities/SpecificEnergy.extra.cs | 44 ------- .../Quantities/SpecificEntropy.extra.cs | 20 --- .../Quantities/SpecificVolume.extra.cs | 20 --- .../Quantities/SpecificWeight.extra.cs | 40 ------ UnitsNet/CustomCode/Quantities/Speed.extra.cs | 76 ------------ .../Quantities/TemperatureChangeRate.extra.cs | 29 ----- .../Quantities/TemperatureDelta.extra.cs | 44 ------- .../Quantities/TemperatureGradient.extra.cs | 23 ---- .../CustomCode/Quantities/Torque.extra.cs | 32 ----- .../CustomCode/Quantities/Volume.extra.cs | 24 ---- .../Quantities/VolumeConcentration.extra.cs | 17 --- .../CustomCode/Quantities/VolumeFlow.extra.cs | 46 ------- .../Quantities/Acceleration.g.cs | 57 +++++++++ .../Quantities/AmountOfSubstance.g.cs | 30 +++++ UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 30 +++++ UnitsNet/GeneratedCode/Quantities/Area.g.cs | 100 +++++++++++++++ .../GeneratedCode/Quantities/AreaDensity.g.cs | 16 +++ .../Quantities/AreaMomentOfInertia.g.cs | 16 +++ .../BrakeSpecificFuelConsumption.g.cs | 29 +++++ .../CoefficientOfThermalExpansion.g.cs | 16 +++ .../GeneratedCode/Quantities/Density.g.cs | 58 +++++++++ .../GeneratedCode/Quantities/Duration.g.cs | 100 +++++++++++++++ .../Quantities/DynamicViscosity.g.cs | 16 +++ .../Quantities/ElectricCharge.g.cs | 37 ++++++ .../Quantities/ElectricConductivity.g.cs | 11 ++ .../Quantities/ElectricCurrent.g.cs | 57 +++++++++ .../Quantities/ElectricCurrentGradient.g.cs | 29 +++++ .../Quantities/ElectricPotential.g.cs | 37 ++++++ .../Quantities/ElectricResistance.g.cs | 16 +++ .../Quantities/ElectricResistivity.g.cs | 11 ++ UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 79 ++++++++++++ .../Quantities/EnergyDensity.g.cs | 16 +++ .../GeneratedCode/Quantities/Entropy.g.cs | 23 ++++ UnitsNet/GeneratedCode/Quantities/Force.g.cs | 79 ++++++++++++ .../Quantities/ForceChangeRate.g.cs | 29 +++++ .../Quantities/ForcePerLength.g.cs | 44 +++++++ .../GeneratedCode/Quantities/Frequency.g.cs | 16 +++ .../GeneratedCode/Quantities/HeatFlux.g.cs | 16 +++ .../Quantities/KinematicViscosity.g.cs | 43 +++++++ UnitsNet/GeneratedCode/Quantities/Length.g.cs | 100 +++++++++++++++ .../Quantities/LinearDensity.g.cs | 30 +++++ .../GeneratedCode/Quantities/Luminance.g.cs | 16 +++ .../Quantities/LuminousIntensity.g.cs | 23 ++++ UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 114 ++++++++++++++++++ .../Quantities/MassConcentration.g.cs | 30 +++++ .../GeneratedCode/Quantities/MassFlow.g.cs | 78 ++++++++++++ .../GeneratedCode/Quantities/MassFlux.g.cs | 30 +++++ .../Quantities/MassFraction.g.cs | 16 +++ .../GeneratedCode/Quantities/MolarFlow.g.cs | 43 +++++++ .../GeneratedCode/Quantities/MolarMass.g.cs | 30 +++++ .../GeneratedCode/Quantities/Molarity.g.cs | 23 ++++ UnitsNet/GeneratedCode/Quantities/Power.g.cs | 99 +++++++++++++++ .../GeneratedCode/Quantities/Pressure.g.cs | 58 +++++++++ .../Quantities/PressureChangeRate.g.cs | 29 +++++ .../Quantities/ReciprocalArea.g.cs | 37 ++++++ .../Quantities/ReciprocalLength.g.cs | 44 +++++++ .../Quantities/RotationalSpeed.g.cs | 29 +++++ .../Quantities/RotationalStiffness.g.cs | 30 +++++ .../RotationalStiffnessPerLength.g.cs | 16 +++ .../Quantities/SpecificEnergy.g.cs | 43 +++++++ .../Quantities/SpecificEntropy.g.cs | 23 ++++ .../Quantities/SpecificVolume.g.cs | 22 ++++ .../Quantities/SpecificWeight.g.cs | 37 ++++++ UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 85 +++++++++++++ .../Quantities/TemperatureChangeRate.g.cs | 29 +++++ .../Quantities/TemperatureDelta.g.cs | 44 +++++++ .../Quantities/TemperatureGradient.g.cs | 16 +++ UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 37 ++++++ UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 58 +++++++++ .../Quantities/VolumeConcentration.g.cs | 23 ++++ .../GeneratedCode/Quantities/VolumeFlow.g.cs | 50 ++++++++ 116 files changed, 2353 insertions(+), 1876 deletions(-) delete mode 100644 UnitsNet/CustomCode/Quantities/Acceleration.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Angle.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/AreaDensity.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/CoefficientOfThermalExpansion.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Density.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ElectricCharge.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ElectricConductivity.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ElectricCurrent.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ElectricCurrentGradient.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ElectricResistance.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ElectricResistivity.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Energy.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Entropy.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ForceChangeRate.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/LinearDensity.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Luminance.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/LuminousIntensity.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/MassFlow.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/MassFlux.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/MolarFlow.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Pressure.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/PressureChangeRate.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ReciprocalArea.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/ReciprocalLength.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/SpecificEntropy.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Speed.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/TemperatureChangeRate.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/TemperatureGradient.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/Torque.extra.cs delete mode 100644 UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs diff --git a/UnitsNet/CustomCode/Quantities/Acceleration.extra.cs b/UnitsNet/CustomCode/Quantities/Acceleration.extra.cs deleted file mode 100644 index 562111afd0..0000000000 --- a/UnitsNet/CustomCode/Quantities/Acceleration.extra.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct Acceleration - { - /// - /// Multiply and to get . - /// - public static SpecificWeight operator *(Acceleration acceleration, Density density) - { - return new SpecificWeight(acceleration.MetersPerSecondSquared * density.KilogramsPerCubicMeter, UnitsNet.Units.SpecificWeightUnit.NewtonPerCubicMeter); - } - - /// - /// Multiply and to get . - /// - public static Speed operator *(Acceleration acceleration, Duration duration) - { - return new Speed(acceleration.MetersPerSecondSquared * duration.Seconds, UnitsNet.Units.SpeedUnit.MeterPerSecond); - } - - /// - /// Divide by to get . - /// - public static Jerk operator /(Acceleration acceleration, Duration duration) - { - return new Jerk(acceleration.MetersPerSecondSquared / duration.Seconds, UnitsNet.Units.JerkUnit.MeterPerSecondCubed); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs index 6fb8944cfe..83b85777cf 100644 --- a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs @@ -39,30 +39,5 @@ public static AmountOfSubstance FromMass(Mass mass, MolarMass molarMass) { return mass / molarMass; } - - /// Get from for a given . - public static Mass operator *(AmountOfSubstance amountOfSubstance, MolarMass molarMass) - { - return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); - } - - /// Get from for a given . - public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) - { - return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); - } - - /// Get from divided by . - public static Molarity operator /(AmountOfSubstance amountOfComponent, Volume mixtureVolume) - { - return Molarity.FromMolesPerCubicMeter(amountOfComponent.Moles / mixtureVolume.CubicMeters); - } - - /// Get from divided by . - public static Volume operator /(AmountOfSubstance amountOfSubstance, Molarity molarity) - { - return Volume.FromCubicMeters(amountOfSubstance.Moles / molarity.MolesPerCubicMeter); - } - } } diff --git a/UnitsNet/CustomCode/Quantities/Angle.extra.cs b/UnitsNet/CustomCode/Quantities/Angle.extra.cs deleted file mode 100644 index 59318915c4..0000000000 --- a/UnitsNet/CustomCode/Quantities/Angle.extra.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct Angle - { - /// Get from delta over time delta. - public static RotationalSpeed operator /(Angle angle, TimeSpan timeSpan) - { - return RotationalSpeed.FromRadiansPerSecond(angle.Radians / timeSpan.TotalSeconds); - } - - /// - public static RotationalSpeed operator /(Angle angle, Duration duration) - { - return RotationalSpeed.FromRadiansPerSecond(angle.Radians / duration.Seconds); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Area.extra.cs b/UnitsNet/CustomCode/Quantities/Area.extra.cs index 8df2a275d3..3a9d28e973 100644 --- a/UnitsNet/CustomCode/Quantities/Area.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Area.extra.cs @@ -23,47 +23,5 @@ public static Area FromCircleRadius(Length radius) } #endregion - - /// - /// Calculates the inverse of this quantity. - /// - /// The corresponding inverse quantity, . - public ReciprocalArea Inverse() - { - if (SquareMeters == 0.0) - return new ReciprocalArea(0.0, UnitsNet.Units.ReciprocalAreaUnit.InverseSquareMeter); - - return new ReciprocalArea(1 / SquareMeters, UnitsNet.Units.ReciprocalAreaUnit.InverseSquareMeter); - } - - /// Get from divided by . - public static Length operator /(Area area, Length length) - { - return Length.FromMeters(area.SquareMeters / length.Meters); - } - - /// Get from times . - public static MassFlow operator *(Area area, MassFlux massFlux) - { - return MassFlow.FromGramsPerSecond(area.SquareMeters * massFlux.GramsPerSecondPerSquareMeter); - } - - /// Get from times . - public static VolumeFlow operator *(Area area, Speed speed) - { - return VolumeFlow.FromCubicMetersPerSecond(area.SquareMeters * speed.MetersPerSecond); - } - - /// Get from times . - public static LinearDensity operator *(Area area, Density density) - { - return LinearDensity.FromKilogramsPerMeter(area.SquareMeters * density.KilogramsPerCubicMeter); - } - - /// Get from times . - public static Ratio operator *(Area area, ReciprocalArea reciprocalArea) - { - return Ratio.FromDecimalFractions(area.SquareMeters * reciprocalArea.InverseSquareMeters); - } } } diff --git a/UnitsNet/CustomCode/Quantities/AreaDensity.extra.cs b/UnitsNet/CustomCode/Quantities/AreaDensity.extra.cs deleted file mode 100644 index 1e92e6f211..0000000000 --- a/UnitsNet/CustomCode/Quantities/AreaDensity.extra.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct AreaDensity - { - /// Get from times . - public static Mass operator *(AreaDensity areaDensity, Area area) - { - return Mass.FromKilograms(areaDensity.KilogramsPerSquareMeter * area.SquareMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs b/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs deleted file mode 100644 index 2d254b9c17..0000000000 --- a/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct AreaMomentOfInertia - { - /// Get from divided by . - public static Volume operator /(AreaMomentOfInertia areaMomentOfInertia, Length length) - { - return Volume.FromCubicMeters(areaMomentOfInertia.MetersToTheFourth / length.Meters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs deleted file mode 100644 index e2bfa67d7a..0000000000 --- a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct BrakeSpecificFuelConsumption - { - /// Get from times . - public static MassFlow operator *(BrakeSpecificFuelConsumption bsfc, Power power) - { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * (double)power.Watts); - } - - /// Get from divided by . - public static SpecificEnergy operator /(double value, BrakeSpecificFuelConsumption bsfc) - { - return SpecificEnergy.FromJoulesPerKilogram(value/bsfc.KilogramsPerJoule); - } - - /// Get constant from times . - public static double operator *(BrakeSpecificFuelConsumption bsfc, SpecificEnergy specificEnergy) - { - return specificEnergy.JoulesPerKilogram*bsfc.KilogramsPerJoule; - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/CoefficientOfThermalExpansion.extra.cs b/UnitsNet/CustomCode/Quantities/CoefficientOfThermalExpansion.extra.cs deleted file mode 100644 index 0a426727fd..0000000000 --- a/UnitsNet/CustomCode/Quantities/CoefficientOfThermalExpansion.extra.cs +++ /dev/null @@ -1,11 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct CoefficientOfThermalExpansion - { - /// Get a scalar from a multiplied by a . - public static double operator *(CoefficientOfThermalExpansion cte, TemperatureDelta temperatureDelta) => cte.PerKelvin * temperatureDelta.Kelvins; - } -} diff --git a/UnitsNet/CustomCode/Quantities/Density.extra.cs b/UnitsNet/CustomCode/Quantities/Density.extra.cs deleted file mode 100644 index fd036dc519..0000000000 --- a/UnitsNet/CustomCode/Quantities/Density.extra.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct Density - { - /// Get from times . - public static Mass operator *(Density density, Volume volume) - { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); - } - - /// Get from times . - public static Mass operator *(Volume volume, Density density) - { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); - } - - /// Get from times . - public static DynamicViscosity operator *(Density density, KinematicViscosity kinematicViscosity) - { - return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); - } - - /// Get times . - public static MassFlux operator *(Density density, Speed speed) - { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); - } - - /// Get from times . - public static SpecificWeight operator *(Density density, Acceleration acceleration) - { - return new SpecificWeight(density.KilogramsPerCubicMeter * acceleration.MetersPerSecondSquared, SpecificWeightUnit.NewtonPerCubicMeter); - } - - /// Get from times . - public static LinearDensity operator *(Density density, Area area) - { - return LinearDensity.FromKilogramsPerMeter(density.KilogramsPerCubicMeter * area.SquareMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Duration.extra.cs b/UnitsNet/CustomCode/Quantities/Duration.extra.cs index e1e898c62d..4333d3c745 100644 --- a/UnitsNet/CustomCode/Quantities/Duration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Duration.extra.cs @@ -92,29 +92,5 @@ public static explicit operator Duration(TimeSpan duration) { return timeSpan.TotalSeconds >= duration.Seconds; } - - /// Get from multiplied by . - public static Volume operator *(Duration duration, VolumeFlow volumeFlow) - { - return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * duration.Seconds); - } - - /// Get from multiplied by . - public static ElectricCharge operator *(Duration time, ElectricCurrent current) - { - return ElectricCharge.FromAmpereHours(current.Amperes * time.Hours); - } - - /// Get from multiplied by . - public static Speed operator *(Duration duration, Acceleration acceleration) - { - return new Speed(acceleration.MetersPerSecondSquared * duration.Seconds, SpeedUnit.MeterPerSecond); - } - - /// Get from multiplied by . - public static Force operator *(Duration duration, ForceChangeRate forceChangeRate) - { - return new Force(forceChangeRate.NewtonsPerSecond * duration.Seconds, ForceUnit.Newton); - } } } diff --git a/UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs b/UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs deleted file mode 100644 index e99348a111..0000000000 --- a/UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct DynamicViscosity - { - /// Get from divided by . - public static KinematicViscosity operator /(DynamicViscosity dynamicViscosity, Density density) - { - return KinematicViscosity.FromSquareMetersPerSecond(dynamicViscosity.NewtonSecondsPerMeterSquared / density.KilogramsPerCubicMeter); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ElectricCharge.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricCharge.extra.cs deleted file mode 100644 index 2ece06a503..0000000000 --- a/UnitsNet/CustomCode/Quantities/ElectricCharge.extra.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct ElectricCharge - { - /// Get from divided by . - public static ElectricCurrent operator /(ElectricCharge charge, Duration time) - { - return ElectricCurrent.FromAmperes(charge.AmpereHours / time.Hours); - } - - /// Get from divided by . - public static Duration operator /(ElectricCharge charge, ElectricCurrent current) - { - return Duration.FromHours(charge.AmpereHours / current.Amperes); - } - - /// Get from times . - public static Energy operator *(ElectricCharge charge, ElectricPotential potential) - { - return Energy.FromJoules(potential.Volts * charge.Coulombs); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ElectricConductivity.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricConductivity.extra.cs deleted file mode 100644 index 120fae5701..0000000000 --- a/UnitsNet/CustomCode/Quantities/ElectricConductivity.extra.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct ElectricConductivity - { - /// - /// Calculates the inverse or of this unit. - /// - /// The inverse or of this unit. - public ElectricResistivity Inverse() - { - if (SiemensPerMeter == 0.0) - return new ElectricResistivity( 0.0, ElectricResistivityUnit.OhmMeter ); - - return new ElectricResistivity( 1 / SiemensPerMeter, ElectricResistivityUnit.OhmMeter ); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ElectricCurrent.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricCurrent.extra.cs deleted file mode 100644 index 8928254f82..0000000000 --- a/UnitsNet/CustomCode/Quantities/ElectricCurrent.extra.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct ElectricCurrent - { - /// Get from multiplied by . - /// Ohm's law implementation - public static ElectricPotential operator *(ElectricCurrent current, ElectricResistance resistance) - { - return ElectricPotential.FromVolts(resistance.Ohms * current.Amperes); - } - - /// Calculate from multiplied by . - /// Electric power is defined as P = U * I. - public static Power operator *(ElectricCurrent current, ElectricPotential potential) - { - return Power.FromWatts(potential.Volts * current.Amperes); - } - - /// Calculate from multiplied by . - public static ElectricCharge operator *(ElectricCurrent current, Duration time) - { - return ElectricCharge.FromAmpereHours(current.Amperes * time.Hours); - } - - /// Get from divided by . - public static ElectricCurrentGradient operator /(ElectricCurrent current, Duration duration) - { - return ElectricCurrentGradient.FromAmperesPerSecond(current.Amperes / duration.Seconds); - } - - /// Get from divided by . - public static ElectricCurrentGradient operator /(ElectricCurrent current, TimeSpan timeSpan) - { - return ElectricCurrentGradient.FromAmperesPerSecond(current.Amperes / timeSpan.TotalSeconds); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ElectricCurrentGradient.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricCurrentGradient.extra.cs deleted file mode 100644 index 11800f51f6..0000000000 --- a/UnitsNet/CustomCode/Quantities/ElectricCurrentGradient.extra.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct ElectricCurrentGradient - { - /// Get from times . - public static ElectricCurrent operator *(ElectricCurrentGradient currentGradient, Duration duration) - { - return ElectricCurrent.FromAmperes(currentGradient.AmperesPerSecond * duration.Seconds); - } - - /// Get from times . - public static ElectricCurrent operator *(ElectricCurrentGradient currentGradient, TimeSpan timeSpan) - { - return ElectricCurrent.FromAmperes(currentGradient.AmperesPerSecond * timeSpan.TotalSeconds); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs index 5ff53c0389..5a807c63c5 100644 --- a/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs +++ b/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs @@ -18,32 +18,5 @@ public AmplitudeRatio ToAmplitudeRatio() { return AmplitudeRatio.FromElectricPotential(this); } - - /// Get from divided by . - /// Ohm's law implementation - public static ElectricResistance operator /(ElectricPotential potential, ElectricCurrent current) - { - return ElectricResistance.FromOhms(potential.Volts / current.Amperes); - } - - /// Get from divided by . - /// Ohm's law implementation - public static ElectricCurrent operator /(ElectricPotential potential, ElectricResistance resistance) - { - return ElectricCurrent.FromAmperes(potential.Volts / resistance.Ohms); - } - - /// Calculate from multiplied by . - /// Electric power is defined as P = U * I. - public static Power operator *(ElectricPotential potential, ElectricCurrent current) - { - return Power.FromWatts(potential.Volts * current.Amperes); - } - - /// Get from times . - public static Energy operator *(ElectricPotential potential, ElectricCharge charge) - { - return Energy.FromJoules(potential.Volts * charge.Coulombs); - } } } diff --git a/UnitsNet/CustomCode/Quantities/ElectricResistance.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricResistance.extra.cs deleted file mode 100644 index 95d103d89e..0000000000 --- a/UnitsNet/CustomCode/Quantities/ElectricResistance.extra.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct ElectricResistance - { - /// Get from multiplied by . - /// Ohm's law implementation - public static ElectricPotential operator *(ElectricResistance resistance, ElectricCurrent current) - { - return ElectricPotential.FromVolts(resistance.Ohms * current.Amperes); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ElectricResistivity.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricResistivity.extra.cs deleted file mode 100644 index f53482d9f2..0000000000 --- a/UnitsNet/CustomCode/Quantities/ElectricResistivity.extra.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct ElectricResistivity - { - /// - /// Calculates the inverse or of this unit. - /// - /// The inverse or of this unit. - public ElectricConductivity Inverse() - { - if (OhmMeters == 0.0) - return new ElectricConductivity( 0, ElectricConductivityUnit.SiemensPerMeter ); - - return new ElectricConductivity( 1 / OhmMeters, ElectricConductivityUnit.SiemensPerMeter ); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Energy.extra.cs b/UnitsNet/CustomCode/Quantities/Energy.extra.cs deleted file mode 100644 index 10fd0ff4ab..0000000000 --- a/UnitsNet/CustomCode/Quantities/Energy.extra.cs +++ /dev/null @@ -1,76 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct Energy - { - /// Get from divided by . - public static Power operator /(Energy energy, TimeSpan time) - { - return Power.FromWatts(energy.Joules / time.TotalSeconds); - } - - /// Get from divided by . - public static Power operator /(Energy energy, Duration duration) - { - return Power.FromWatts(energy.Joules / duration.Seconds); - } - - /// Get from divided by . - public static Duration operator /(Energy energy, Power power) - { - return Duration.FromSeconds(energy.Joules / (double)power.Watts); - } - - /// Get from divided by . - public static ElectricCharge operator /(Energy energy, ElectricPotential potential) - { - return ElectricCharge.FromCoulombs(energy.Joules / potential.Volts); - } - - /// Get from divided by . - public static ElectricPotential operator /(Energy energy, ElectricCharge current) - { - return ElectricPotential.FromVolts(energy.Joules / current.Coulombs); - } - - /// Get from times . - public static Power operator *(Energy energy, Frequency frequency) - { - return Power.FromWatts(energy.Joules * frequency.PerSecond); - } - - /// Get from times . - public static Power operator *(Frequency frequency, Energy energy) - { - return Power.FromWatts(energy.Joules * frequency.PerSecond); - } - - /// Get from divided by - public static Entropy operator /(Energy energy, TemperatureDelta temperatureDelta) - { - return Entropy.FromJoulesPerKelvin(energy.Joules / temperatureDelta.Kelvins); - } - - /// Get from divided by . - public static TemperatureDelta operator /(Energy energy, Entropy entropy) - { - return TemperatureDelta.FromKelvins(energy.Joules / entropy.JoulesPerKelvin); - } - - /// Get from divided by - public static SpecificEnergy operator /(Energy energy, Mass mass) - { - return SpecificEnergy.FromJoulesPerKilogram(energy.Joules / mass.Kilograms); - } - - /// Get from divided by . - public static Mass operator /(Energy energy, SpecificEnergy specificEnergy) - { - return Mass.FromKilograms(energy.Joules / specificEnergy.JoulesPerKilogram); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/EnergyDensity.extra.cs b/UnitsNet/CustomCode/Quantities/EnergyDensity.extra.cs index d2fda8070b..811267d7f9 100644 --- a/UnitsNet/CustomCode/Quantities/EnergyDensity.extra.cs +++ b/UnitsNet/CustomCode/Quantities/EnergyDensity.extra.cs @@ -4,20 +4,6 @@ namespace UnitsNet { public partial struct EnergyDensity { - #region Operators - - /// - /// Returns the from the given and . - /// - public static Energy operator * ( EnergyDensity energyDensity, Volume volume ) - { - return Energy.FromJoules ( energyDensity.JoulesPerCubicMeter * volume.As ( VolumeUnit.CubicMeter ) ); - } - - #endregion - - #region Methods - /// /// Computes the combustion energy of a natural gas heating system. /// @@ -46,7 +32,5 @@ public static Energy CombustionEnergy ( EnergyDensity energyDensity, Volume volu { return Energy.FromJoules ( (energyDensity * volume).As ( EnergyUnit.Joule ) * conversionFactor.DecimalFractions ); } - - #endregion } } diff --git a/UnitsNet/CustomCode/Quantities/Entropy.extra.cs b/UnitsNet/CustomCode/Quantities/Entropy.extra.cs deleted file mode 100644 index 5b3d45c313..0000000000 --- a/UnitsNet/CustomCode/Quantities/Entropy.extra.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct Entropy - { - /// Get from divided by . - public static SpecificEntropy operator /(Entropy entropy, Mass mass) - { - return SpecificEntropy.FromJoulesPerKilogramKelvin(entropy.JoulesPerKelvin / mass.Kilograms); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Force.extra.cs b/UnitsNet/CustomCode/Quantities/Force.extra.cs index 7972c0f412..d729d18b18 100644 --- a/UnitsNet/CustomCode/Quantities/Force.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Force.extra.cs @@ -19,59 +19,5 @@ public static Force FromMassByAcceleration(Mass mass, Acceleration acceleration) { return new Force(mass.Kilograms * acceleration.MetersPerSecondSquared, ForceUnit.Newton); } - - /// Get from times . - public static Power operator *(Force force, Speed speed) - { - return Power.FromWatts(force.Newtons * speed.MetersPerSecond); - } - - /// Get from times . - public static Power operator *(Speed speed, Force force) - { - return Power.FromWatts(force.Newtons * speed.MetersPerSecond); - } - - /// Get from times . - public static ForcePerLength operator *(Force force, ReciprocalLength reciprocalLength) - { - return ForcePerLength.FromNewtonsPerMeter(force.Newtons * reciprocalLength.InverseMeters); - } - - /// Get from times . - public static Pressure operator *(Force force, ReciprocalArea reciprocalArea) - { - return Pressure.FromNewtonsPerSquareMeter(force.Newtons * reciprocalArea.InverseSquareMeters); - } - - /// Get from divided by . - public static Acceleration operator /(Force force, Mass mass) - { - return Acceleration.FromMetersPerSecondSquared(force.Newtons / mass.Kilograms); - } - - /// Get from divided by . - public static Mass operator /(Force force, Acceleration acceleration) - { - return Mass.FromKilograms(force.Newtons / acceleration.MetersPerSecondSquared); - } - - /// Get from divided by . - public static Pressure operator /(Force force, Area area) - { - return Pressure.FromPascals(force.Newtons / area.SquareMeters); - } - - /// Get from divided by . - public static ForcePerLength operator /(Force force, Length length) - { - return ForcePerLength.FromNewtonsPerMeter(force.Newtons / length.Meters); - } - - /// Get from divided by . - public static Duration operator /(Force force, ForceChangeRate forceChangeRate) - { - return new Duration(force.Newtons / forceChangeRate.NewtonsPerSecond, DurationUnit.Second); - } } } diff --git a/UnitsNet/CustomCode/Quantities/ForceChangeRate.extra.cs b/UnitsNet/CustomCode/Quantities/ForceChangeRate.extra.cs deleted file mode 100644 index 4880daadde..0000000000 --- a/UnitsNet/CustomCode/Quantities/ForceChangeRate.extra.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct ForceChangeRate - { - /// Get from multiplied by . - public static Force operator *(ForceChangeRate forceChangeRate, Duration duration) - { - return new Force(forceChangeRate.NewtonsPerSecond * duration.Seconds, ForceUnit.Newton); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs b/UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs deleted file mode 100644 index 5c37361248..0000000000 --- a/UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct ForcePerLength - { - /// Get from multiplied by . - public static Force operator *(ForcePerLength forcePerLength, Length length) - { - return Force.FromNewtons(forcePerLength.NewtonsPerMeter * length.Meters); - } - - /// Get from divided by . - public static Length operator /(Force force, ForcePerLength forcePerLength) - { - return Length.FromMeters(force.Newtons / forcePerLength.NewtonsPerMeter); - } - - /// Get from divided by . - public static Pressure operator /(ForcePerLength forcePerLength, Length length) - { - return Pressure.FromNewtonsPerSquareMeter(forcePerLength.NewtonsPerMeter / length.Meters); - } - - /// Get from multiplied by . - public static Torque operator *(ForcePerLength forcePerLength, Area area) - { - return Torque.FromNewtonMeters(forcePerLength.NewtonsPerMeter * area.SquareMeters); - } - - /// Get from multiplied by . - public static Pressure operator *(ForcePerLength forcePerLength, ReciprocalLength reciprocalLength) - { - return Pressure.FromNewtonsPerSquareMeter(forcePerLength.NewtonsPerMeter * reciprocalLength.InverseMeters); - } - - /// Get from divided by . - public static Force operator /(ForcePerLength forcePerLength, ReciprocalLength reciprocalLength) - { - return Force.FromNewtons(forcePerLength.NewtonsPerMeter / reciprocalLength.InverseMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs b/UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs deleted file mode 100644 index 395661fb1f..0000000000 --- a/UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct HeatFlux - { - /// Get from times . - public static Power operator *(HeatFlux heatFlux, Area area) - { - return Power.FromWatts(heatFlux.WattsPerSquareMeter * area.SquareMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs b/UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs deleted file mode 100644 index f43b75534c..0000000000 --- a/UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct KinematicViscosity - { - /// Get from divided by . - public static Speed operator /(KinematicViscosity kinematicViscosity, Length length) - { - return Speed.FromMetersPerSecond(kinematicViscosity.SquareMetersPerSecond / length.Meters); - } - - /// Get from times . - public static Area operator *(KinematicViscosity kinematicViscosity, TimeSpan timeSpan) - { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); - } - - /// Get from times . - public static Area operator *(TimeSpan timeSpan, KinematicViscosity kinematicViscosity) - { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); - } - - /// Get from times . - public static Area operator *(KinematicViscosity kinematicViscosity, Duration duration) - { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); - } - - /// Get from times . - public static Area operator *(Duration duration, KinematicViscosity kinematicViscosity) - { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); - } - - /// Get from times . - public static DynamicViscosity operator *(KinematicViscosity kinematicViscosity, Density density) - { - return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs index 7c41035344..3d251b249f 100644 --- a/UnitsNet/CustomCode/Quantities/Length.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs @@ -13,17 +13,6 @@ public partial struct Length { private const double InchesInOneFoot = 12; - /// - /// Calculates the inverse of this unit. - /// - /// The inverse of this unit as . - public ReciprocalLength Inverse() - { - return Meters == 0.0 - ? new ReciprocalLength(0.0, ReciprocalLengthUnit.InverseMeter) - : new ReciprocalLength(1 / Meters, ReciprocalLengthUnit.InverseMeter); - } - /// /// Converts the length to a customary feet/inches combination. /// @@ -122,66 +111,6 @@ public static bool TryParseFeetInches(string? str, out Length result, IFormatPro result = default; return false; } - - /// Get from divided by . - public static Speed operator /(Length length, TimeSpan timeSpan) - { - return Speed.FromMetersPerSecond(length.Meters/timeSpan.TotalSeconds); - } - - /// Get from divided by . - public static Speed operator /(Length length, Duration duration) - { - return Speed.FromMetersPerSecond(length.Meters/duration.Seconds); - } - - /// Get from divided by . - public static Duration operator /(Length length, Speed speed) - { - return Duration.FromSeconds(length.Meters/speed.MetersPerSecond); - } - - /// Get from times . - public static Area operator *(Length length1, Length length2) - { - return Area.FromSquareMeters(length1.Meters*length2.Meters); - } - - /// Get from times . - public static Volume operator *(Area area, Length length) - { - return Volume.FromCubicMeters(area.SquareMeters*length.Meters); - } - - /// Get from times . - public static Volume operator *(Length length, Area area) - { - return Volume.FromCubicMeters(area.SquareMeters*length.Meters); - } - - /// Get from times . - public static Torque operator *(Force force, Length length) - { - return Torque.FromNewtonMeters(force.Newtons*length.Meters); - } - - /// Get from times . - public static Torque operator *(Length length, Force force) - { - return Torque.FromNewtonMeters(force.Newtons*length.Meters); - } - - /// Get from times . - public static KinematicViscosity operator *(Length length, Speed speed) - { - return KinematicViscosity.FromSquareMetersPerSecond(length.Meters*speed.MetersPerSecond); - } - - /// Get from times . - public static Pressure operator *(Length length, SpecificWeight specificWeight) - { - return new Pressure(length.Meters * specificWeight.NewtonsPerCubicMeter, PressureUnit.Pascal); - } } /// diff --git a/UnitsNet/CustomCode/Quantities/LinearDensity.extra.cs b/UnitsNet/CustomCode/Quantities/LinearDensity.extra.cs deleted file mode 100644 index 1b4740e08d..0000000000 --- a/UnitsNet/CustomCode/Quantities/LinearDensity.extra.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct LinearDensity - { - - /// Get from times . - public static Density operator /(LinearDensity linearDensity, Area area) - { - return Density.FromKilogramsPerCubicMeter(linearDensity.KilogramsPerMeter / area.SquareMeters); - } - - /// Get from times . - public static Area operator /(LinearDensity linearDensity, Density density) - { - return Area.FromSquareMeters(linearDensity.KilogramsPerMeter / density.KilogramsPerCubicMeter); - } - - /// Get from times . - public static Mass operator *(LinearDensity linearDensity, Length length) - { - return Mass.FromKilograms(linearDensity.KilogramsPerMeter * length.Meters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Luminance.extra.cs b/UnitsNet/CustomCode/Quantities/Luminance.extra.cs deleted file mode 100644 index 25d59b34cc..0000000000 --- a/UnitsNet/CustomCode/Quantities/Luminance.extra.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct Luminance - { - /// Get from times . - public static LuminousIntensity operator *(Luminance luminance, Area area) - { - return LuminousIntensity.FromCandela(luminance.CandelasPerSquareMeter * area.SquareMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/LuminousIntensity.extra.cs b/UnitsNet/CustomCode/Quantities/LuminousIntensity.extra.cs deleted file mode 100644 index b2f5960f7b..0000000000 --- a/UnitsNet/CustomCode/Quantities/LuminousIntensity.extra.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct LuminousIntensity - { - /// Get from divided by . - public static Luminance operator /(LuminousIntensity luminousIntensity, Area area) - { - return Luminance.FromCandelasPerSquareMeter(luminousIntensity.Candela / area.SquareMeters); - } - - /// Get from divided by . - public static Area operator /(LuminousIntensity luminousIntensity, Luminance luminance) - { - return Area.FromSquareMeters(luminousIntensity.Candela / luminance.CandelasPerSquareMeter); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs index e82862fc21..906feca314 100644 --- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs @@ -45,72 +45,6 @@ public static Mass FromStonePounds(double stone, double pounds) { return FromPounds(StonesInOnePound*stone + pounds); } - - /// Get from divided by . - public static MassFlow operator /(Mass mass, TimeSpan timeSpan) - { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms/timeSpan.TotalSeconds); - } - - /// Get from divided by . - public static MassFlow operator /(Mass mass, Duration duration) - { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms/duration.Seconds); - } - - /// Get from divided by . - public static Density operator /(Mass mass, Volume volume) - { - return Density.FromKilogramsPerCubicMeter(mass.Kilograms/volume.CubicMeters); - } - - /// Get from divided by . - public static Volume operator /(Mass mass, Density density) - { - return Volume.FromCubicMeters(mass.Kilograms / density.KilogramsPerCubicMeter); - } - - /// Get from divided by . - public static AmountOfSubstance operator /(Mass mass, MolarMass molarMass) - { - return AmountOfSubstance.FromMoles(mass.Kilograms / molarMass.KilogramsPerMole); - } - - /// Get from divided by . - public static AreaDensity operator /(Mass mass, Area area) - { - return AreaDensity.FromKilogramsPerSquareMeter(mass.Kilograms / area.SquareMeters); - } - - /// Get from divided by . - public static Area operator /(Mass mass, AreaDensity areaDensity) - { - return Area.FromSquareMeters(mass.Kilograms / areaDensity.KilogramsPerSquareMeter); - } - - /// Get from times . - public static Force operator *(Mass mass, Acceleration acceleration) - { - return Force.FromNewtons(mass.Kilograms*acceleration.MetersPerSecondSquared); - } - - /// Get from times . - public static Force operator *(Acceleration acceleration, Mass mass) - { - return Force.FromNewtons(mass.Kilograms*acceleration.MetersPerSecondSquared); - } - - /// Get from times . - public static LinearDensity operator /(Mass mass, Length length) - { - return LinearDensity.FromKilogramsPerMeter(mass.Kilograms / length.Meters); - } - - /// Get from divided by . - public static Length operator /(Mass mass, LinearDensity linearDensity) - { - return Length.FromMeters(mass.Kilograms / linearDensity.KilogramsPerMeter); - } } /// diff --git a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs index 3e02c6e53d..569c228523 100644 --- a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs @@ -43,34 +43,5 @@ public static MassConcentration FromVolumeConcentration(VolumeConcentration volu } #endregion - - #region Operators - - /// Get from times . - public static Mass operator *(MassConcentration density, Volume volume) - { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); - } - - /// Get from times . - public static Mass operator *(Volume volume, MassConcentration density) - { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); - } - - /// Get from divided by the component's . - public static Molarity operator /(MassConcentration massConcentration, MolarMass componentMass) - { - return Molarity.FromMolesPerCubicMeter(massConcentration.GramsPerCubicMeter / componentMass.GramsPerMole); - } - - /// Get from divided by the component's . - public static VolumeConcentration operator /(MassConcentration massConcentration, Density componentDensity) - { - return VolumeConcentration.FromDecimalFractions(massConcentration.KilogramsPerCubicMeter / componentDensity.KilogramsPerCubicMeter); - } - - #endregion - } } diff --git a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs deleted file mode 100644 index 47ed64f065..0000000000 --- a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs +++ /dev/null @@ -1,76 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct MassFlow - { - /// Get from times . - public static Mass operator *(MassFlow massFlow, TimeSpan time) - { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); - } - - /// Get from times . - public static Mass operator *(TimeSpan time, MassFlow massFlow) - { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); - } - - /// Get from times . - public static Mass operator *(MassFlow massFlow, Duration duration) - { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); - } - - /// Get from times . - public static Mass operator *(Duration duration, MassFlow massFlow) - { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); - } - - /// Get from divided by . - public static Power operator /(MassFlow massFlow, BrakeSpecificFuelConsumption bsfc) - { - return Power.FromWatts(massFlow.KilogramsPerSecond / bsfc.KilogramsPerJoule); - } - - /// Get from divided by . - public static BrakeSpecificFuelConsumption operator /(MassFlow massFlow, Power power) - { - return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / (double)power.Watts); - } - - /// Get from times . - public static Power operator *(MassFlow massFlow, SpecificEnergy specificEnergy) - { - return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); - } - - /// Get from divided by . - public static MassFlux operator /(MassFlow massFlow, Area area) - { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); - } - - /// Get from divided by . - public static Area operator /(MassFlow massFlow, MassFlux massFlux) - { - return Area.FromSquareMeters(massFlow.KilogramsPerSecond / massFlux.KilogramsPerSecondPerSquareMeter); - } - - /// Get from divided by . - public static Density operator /(MassFlow massFlow, VolumeFlow volumeFlow) - { - return Density.FromKilogramsPerCubicMeter(massFlow.KilogramsPerSecond / volumeFlow.CubicMetersPerSecond); - } - - /// Get from divided by . - public static VolumeFlow operator /(MassFlow massFlow, Density density) - { - return VolumeFlow.FromCubicMetersPerSecond(massFlow.KilogramsPerSecond / density.KilogramsPerCubicMeter); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/MassFlux.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlux.extra.cs deleted file mode 100644 index 654ce48a20..0000000000 --- a/UnitsNet/CustomCode/Quantities/MassFlux.extra.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct MassFlux - { - /// Get from divided by . - public static Density operator /(MassFlux massFlux, Speed speed) - { - return Density.FromKilogramsPerCubicMeter(massFlux.KilogramsPerSecondPerSquareMeter / speed.MetersPerSecond); - } - - /// Get from divided by . - public static Speed operator /(MassFlux massFlux, Density density) - { - return Speed.FromMetersPerSecond(massFlux.KilogramsPerSecondPerSquareMeter / density.KilogramsPerCubicMeter); - } - - /// Get from times . - public static MassFlow operator *(MassFlux massFlux, Area area) - { - return MassFlow.FromGramsPerSecond(massFlux.GramsPerSecondPerSquareMeter * area.SquareMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs b/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs index c685887214..b7c1112740 100644 --- a/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs @@ -35,23 +35,5 @@ public static MassFraction FromMasses(Mass componentMass, Mass mixtureMass) } #endregion - - /// Get from multiplied by a . - public static Mass operator *(MassFraction massFraction, Mass mass) - { - return Mass.FromKilograms(massFraction.DecimalFractions * mass.Kilograms); - } - - /// Get from multiplied by a . - public static Mass operator *(Mass mass, MassFraction massFraction) - { - return Mass.FromKilograms(massFraction.DecimalFractions * mass.Kilograms); - } - /// Get the total by dividing the component by a . - public static Mass operator /(Mass mass, MassFraction massFraction) - { - return Mass.FromKilograms(mass.Kilograms / massFraction.DecimalFractions); - } - } } diff --git a/UnitsNet/CustomCode/Quantities/MolarFlow.extra.cs b/UnitsNet/CustomCode/Quantities/MolarFlow.extra.cs deleted file mode 100644 index 9a69147ce3..0000000000 --- a/UnitsNet/CustomCode/Quantities/MolarFlow.extra.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; - -namespace UnitsNet -{ - public partial struct MolarFlow - { - /// Get from times . - public static AmountOfSubstance operator *(MolarFlow molarFlow, TimeSpan timeSpan) - { - return AmountOfSubstance.FromKilomoles(molarFlow.KilomolesPerSecond * timeSpan.TotalSeconds); - } - - /// Get from times . - public static AmountOfSubstance operator *(MolarFlow molarFlow, Duration duration) - { - return AmountOfSubstance.FromKilomoles(molarFlow.KilomolesPerSecond * duration.Seconds); - } - - /// Get from times . - public static MassFlow operator *(MolarFlow molarFlow, MolarMass molecularWeight) - { - return MassFlow.FromKilogramsPerSecond(molarFlow.KilomolesPerSecond * molecularWeight.KilogramsPerKilomole); - } - - /// Get from divided by . - public static VolumeFlow operator /(MolarFlow molarFlow, Molarity molarity) - { - return VolumeFlow.FromCubicMetersPerSecond(molarFlow.KilomolesPerSecond / molarity.KilomolesPerCubicMeter); - } - - } -} diff --git a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs index 05bad46e43..32203f21f7 100644 --- a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs @@ -38,34 +38,5 @@ public static Molarity FromVolumeConcentration(VolumeConcentration volumeConcent } #endregion - - #region Operators - - /// Get from times the . - public static MassConcentration operator *(Molarity molarity, MolarMass componentMass) - { - return MassConcentration.FromGramsPerCubicMeter(molarity.MolesPerCubicMeter * componentMass.GramsPerMole); - } - - /// Get from times the . - public static MassConcentration operator *(MolarMass componentMass, Molarity molarity) - { - return MassConcentration.FromGramsPerCubicMeter(molarity.MolesPerCubicMeter * componentMass.GramsPerMole); - } - - /// Get from diluting the current by the given . - public static Molarity operator *(Molarity molarity, VolumeConcentration volumeConcentration) - { - return new Molarity(molarity.MolesPerCubicMeter * volumeConcentration.DecimalFractions, MolarityUnit.MolePerCubicMeter); - } - - /// Get from diluting the current by the given . - public static Molarity operator *(VolumeConcentration volumeConcentration, Molarity molarity) - { - return new Molarity(molarity.MolesPerCubicMeter * volumeConcentration.DecimalFractions, MolarityUnit.MolePerCubicMeter); - } - - #endregion - } } diff --git a/UnitsNet/CustomCode/Quantities/Power.extra.cs b/UnitsNet/CustomCode/Quantities/Power.extra.cs index 562192b2f4..b16eec0c63 100644 --- a/UnitsNet/CustomCode/Quantities/Power.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Power.extra.cs @@ -20,91 +20,5 @@ public PowerRatio ToPowerRatio() { return PowerRatio.FromPower(this); } - - /// Get from times . - public static Energy operator *(Power power, TimeSpan time) - { - return Energy.FromJoules((double)power.Watts * time.TotalSeconds); - } - - /// Get from times . - public static Energy operator *(TimeSpan time, Power power) - { - return Energy.FromJoules((double)power.Watts * time.TotalSeconds); - } - - /// Get from times . - public static Energy operator *(Power power, Duration duration) - { - return Energy.FromJoules((double)power.Watts * duration.Seconds); - } - - /// Get from times . - public static Energy operator *(Duration duration, Power power) - { - return Energy.FromJoules((double)power.Watts * duration.Seconds); - } - - /// Get from divided by . - public static Force operator /(Power power, Speed speed) - { - return Force.FromNewtons((double)power.Watts / speed.MetersPerSecond); - } - - /// Get from divided by . - public static Torque operator /(Power power, RotationalSpeed rotationalSpeed) - { - return Torque.FromNewtonMeters((double)power.Watts / rotationalSpeed.RadiansPerSecond); - } - - /// Get from divided by . - public static RotationalSpeed operator /(Power power, Torque torque) - { - return RotationalSpeed.FromRadiansPerSecond((double)power.Watts / torque.NewtonMeters); - } - - /// Get from times . - public static MassFlow operator *(Power power, BrakeSpecificFuelConsumption bsfc) - { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * (double)power.Watts); - } - - /// Get from divided by . - public static SpecificEnergy operator /(Power power, MassFlow massFlow) - { - return SpecificEnergy.FromJoulesPerKilogram((double)power.Watts / massFlow.KilogramsPerSecond); - } - - /// Get from divided by . - public static MassFlow operator /(Power power, SpecificEnergy specificEnergy) - { - return MassFlow.FromKilogramsPerSecond((double)power.Watts / specificEnergy.JoulesPerKilogram); - } - - /// Get from divided by . - public static HeatFlux operator /(Power power, Area area) - { - return HeatFlux.FromWattsPerSquareMeter((double)power.Watts / area.SquareMeters); - } - - /// Get from divided by . - public static Area operator /(Power power, HeatFlux heatFlux) - { - return Area.FromSquareMeters((double)power.Watts / heatFlux.WattsPerSquareMeter ); - } - - /// Calculate from divided by . - /// Electric power is defined as P = U * I, so I = P / U. - public static ElectricCurrent operator /(Power power, ElectricPotential potential) - { - return ElectricCurrent.FromAmperes((double)power.Watts / potential.Volts); - } - - /// Calculate from divided by . - /// Electric power is defined as P = U * I, so I = P / U. - public static ElectricPotential operator /(Power power, ElectricCurrent current) - { - return ElectricPotential.FromVolts((double)power.Watts / current.Amperes); - } } } diff --git a/UnitsNet/CustomCode/Quantities/Pressure.extra.cs b/UnitsNet/CustomCode/Quantities/Pressure.extra.cs deleted file mode 100644 index 259771f8dc..0000000000 --- a/UnitsNet/CustomCode/Quantities/Pressure.extra.cs +++ /dev/null @@ -1,58 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct Pressure - { - /// Get from times . - public static Force operator *(Pressure pressure, Area area) - { - return Force.FromNewtons(pressure.Pascals * area.SquareMeters); - } - - /// Get from times . - public static Force operator *(Area area, Pressure pressure) - { - return Force.FromNewtons(pressure.Pascals * area.SquareMeters); - } - - /// Get from divided by . - public static Length operator /(Pressure pressure, SpecificWeight specificWeight) - { - return new Length(pressure.Pascals / specificWeight.NewtonsPerCubicMeter, UnitsNet.Units.LengthUnit.Meter); - } - - /// Get from divided by . - public static SpecificWeight operator /(Pressure pressure, Length length) - { - return new SpecificWeight(pressure.Pascals / length.Meters, UnitsNet.Units.SpecificWeightUnit.NewtonPerCubicMeter); - } - - /// Get from divided by . - public static ForcePerLength operator /(Pressure pressure, ReciprocalLength reciprocalLength) - { - return new ForcePerLength(pressure.Pascals / reciprocalLength.InverseMeters, UnitsNet.Units.ForcePerLengthUnit.NewtonPerMeter); - } - - /// Get from divided by . - public static Force operator /(Pressure pressure, ReciprocalArea reciprocalArea) - { - return new Force(pressure.Pascals / reciprocalArea.InverseSquareMeters, UnitsNet.Units.ForceUnit.Newton); - } - - /// Get from divided by - public static PressureChangeRate operator /(Pressure pressure, TimeSpan timeSpan) - { - return new PressureChangeRate(pressure.Pascals / timeSpan.TotalSeconds , UnitsNet.Units.PressureChangeRateUnit.PascalPerSecond); - } - - /// Get from divided by - public static PressureChangeRate operator /(Pressure pressure, Duration duration) - { - return new PressureChangeRate(pressure.Pascals / duration.Seconds, UnitsNet.Units.PressureChangeRateUnit.PascalPerSecond); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/PressureChangeRate.extra.cs b/UnitsNet/CustomCode/Quantities/PressureChangeRate.extra.cs deleted file mode 100644 index 1d2359459e..0000000000 --- a/UnitsNet/CustomCode/Quantities/PressureChangeRate.extra.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct PressureChangeRate - { - /// Get from times - public static Pressure operator *(PressureChangeRate pressureChangeRate, TimeSpan timeSpan) - { - return new Pressure(pressureChangeRate.PascalsPerSecond * timeSpan.TotalSeconds , UnitsNet.Units.PressureUnit.Pascal); - } - - /// Get from times - public static Pressure operator *(PressureChangeRate pressureChangeRate, Duration duration) - { - return new Pressure(pressureChangeRate.PascalsPerSecond * duration.Seconds, UnitsNet.Units.PressureUnit.Pascal); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ReciprocalArea.extra.cs b/UnitsNet/CustomCode/Quantities/ReciprocalArea.extra.cs deleted file mode 100644 index 067fd556f0..0000000000 --- a/UnitsNet/CustomCode/Quantities/ReciprocalArea.extra.cs +++ /dev/null @@ -1,40 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct ReciprocalArea - { - /// - /// Calculates the inverse of this quantity. - /// - /// The corresponding inverse quantity, . - public Area Inverse() - { - if (InverseSquareMeters == 0.0) - return new Area(0.0, AreaUnit.SquareMeter); - - return new Area(1 / InverseSquareMeters, AreaUnit.SquareMeter); - } - - /// Get from multiplied by . - public static Pressure operator *(ReciprocalArea reciprocalArea, Force force) - { - return Pressure.FromNewtonsPerSquareMeter(reciprocalArea.InverseSquareMeters * force.Newtons); - } - - /// Get from multiplied by . - public static Ratio operator *(ReciprocalArea reciprocalArea, Area area) - { - return new Ratio(reciprocalArea.InverseSquareMeters * area.SquareMeters, RatioUnit.DecimalFraction); - } - - /// Get from divided by . - public static ReciprocalLength operator /(ReciprocalArea reciprocalArea, ReciprocalLength reciprocalLength) - { - return ReciprocalLength.FromInverseMeters(reciprocalArea.InverseSquareMeters / reciprocalLength.InverseMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/ReciprocalLength.extra.cs b/UnitsNet/CustomCode/Quantities/ReciprocalLength.extra.cs deleted file mode 100644 index caf649773c..0000000000 --- a/UnitsNet/CustomCode/Quantities/ReciprocalLength.extra.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct ReciprocalLength - { - /// - /// Calculates the inverse of this quantity. - /// - /// The corresponding inverse quantity, . - public Length Inverse() - { - if (InverseMeters == 0.0) - return new Length(0.0, LengthUnit.Meter); - - return new Length(1 / InverseMeters, LengthUnit.Meter); - } - - /// Get from multiplied by . - public static Pressure operator *(ReciprocalLength reciprocalLength, ForcePerLength forcePerLength) - { - return Pressure.FromNewtonsPerSquareMeter(reciprocalLength.InverseMeters * forcePerLength.NewtonsPerMeter); - } - - /// Get from times . - public static ForcePerLength operator *(ReciprocalLength reciprocalLength, Force force) - { - return ForcePerLength.FromNewtonsPerMeter(reciprocalLength.InverseMeters * force.Newtons); - } - - /// Get from times . - public static ReciprocalArea operator *(ReciprocalLength reciprocalLength, ReciprocalLength other) - { - return ReciprocalArea.FromInverseSquareMeters(reciprocalLength.InverseMeters * other.InverseMeters); - } - - /// Get from times . - public static Length operator /(ReciprocalLength reciprocalLength, ReciprocalArea reciprocalArea) - { - return Length.FromMeters(reciprocalLength.InverseMeters / reciprocalArea.InverseSquareMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs b/UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs deleted file mode 100644 index a1f18c79cd..0000000000 --- a/UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct RotationalSpeed - { - /// Get from times . - public static Angle operator *(RotationalSpeed rotationalSpeed, TimeSpan timeSpan) - { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); - } - - /// Get from times . - public static Angle operator *(TimeSpan timeSpan, RotationalSpeed rotationalSpeed) - { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); - } - - /// Get from times . - public static Angle operator *(RotationalSpeed rotationalSpeed, Duration duration) - { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); - } - - /// Get from times . - public static Angle operator *(Duration duration, RotationalSpeed rotationalSpeed) - { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs b/UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs deleted file mode 100644 index 48b9342455..0000000000 --- a/UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct RotationalStiffness - { - /// Get from times . - public static Torque operator *(RotationalStiffness rotationalStiffness, Angle angle) - { - return Torque.FromNewtonMeters(rotationalStiffness.NewtonMetersPerRadian * angle.Radians); - } - - /// Get from divided by . - public static RotationalStiffnessPerLength operator /(RotationalStiffness rotationalStiffness, Length length) - { - return RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(rotationalStiffness.NewtonMetersPerRadian / length.Meters); - } - - /// Get from divided by . - public static Length operator /(RotationalStiffness rotationalStiffness, RotationalStiffnessPerLength rotationalStiffnessPerLength) - { - return Length.FromMeters(rotationalStiffness.NewtonMetersPerRadian / rotationalStiffnessPerLength.NewtonMetersPerRadianPerMeter); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs b/UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs deleted file mode 100644 index 1aef772c05..0000000000 --- a/UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - public partial struct RotationalStiffnessPerLength - { - /// Get from times . - public static RotationalStiffness operator *(RotationalStiffnessPerLength rotationalStiffness, Length length) - { - return RotationalStiffness.FromNewtonMetersPerRadian(rotationalStiffness.NewtonMetersPerRadianPerMeter * length.Meters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs deleted file mode 100644 index d90dcf8de5..0000000000 --- a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct SpecificEnergy - { - /// Get from times . - public static Energy operator *(SpecificEnergy specificEnergy, Mass mass) - { - return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); - } - - /// Get from times . - public static Energy operator *(Mass mass, SpecificEnergy specificEnergy) - { - return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); - } - - /// Get from divided by . - public static BrakeSpecificFuelConsumption operator /(double value, SpecificEnergy specificEnergy) - { - return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value / specificEnergy.JoulesPerKilogram); - } - - /// Get from times . - public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption bsfc) - { - return specificEnergy.JoulesPerKilogram * bsfc.KilogramsPerJoule; - } - - /// Get from times . - public static Power operator *(SpecificEnergy specificEnergy, MassFlow massFlow) - { - return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); - } - - /// Get from divided by . - public static SpecificEntropy operator /(SpecificEnergy specificEnergy, TemperatureDelta temperatureDelta) - { - return SpecificEntropy.FromJoulesPerKilogramKelvin(specificEnergy.JoulesPerKilogram / temperatureDelta.Kelvins); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/SpecificEntropy.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificEntropy.extra.cs deleted file mode 100644 index 96b2f1e58e..0000000000 --- a/UnitsNet/CustomCode/Quantities/SpecificEntropy.extra.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct SpecificEntropy - { - /// Get from times . - public static Entropy operator *(SpecificEntropy specificEntropy, Mass mass) - { - return Entropy.FromJoulesPerKelvin(specificEntropy.JoulesPerKilogramKelvin * mass.Kilograms); - } - - /// Get from times . - public static Entropy operator *(Mass mass, SpecificEntropy specificEntropy) - { - return Entropy.FromJoulesPerKelvin(specificEntropy.JoulesPerKilogramKelvin * mass.Kilograms); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs deleted file mode 100644 index f284f8bb28..0000000000 --- a/UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct SpecificVolume - { - /// Get from divided by . - public static Density operator /(double constant, SpecificVolume volume) - { - return Density.FromKilogramsPerCubicMeter(constant / volume.CubicMetersPerKilogram); - } - - /// Get from times . - public static Volume operator *(SpecificVolume volume, Mass mass) - { - return Volume.FromCubicMeters(volume.CubicMetersPerKilogram * mass.Kilograms); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs deleted file mode 100644 index 0a6bd6e6d9..0000000000 --- a/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs +++ /dev/null @@ -1,40 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct SpecificWeight - { - /// Get from times . - public static Pressure operator *(SpecificWeight specificWeight, Length length) - { - return new Pressure(specificWeight.NewtonsPerCubicMeter * length.Meters, PressureUnit.Pascal); - } - - /// Get from times . - public static ForcePerLength operator *(SpecificWeight specificWeight, Area area) - { - return new ForcePerLength(specificWeight.NewtonsPerCubicMeter * area.SquareMeters, ForcePerLengthUnit.NewtonPerMeter); - } - - /// Get from times . - public static ForcePerLength operator *(Area area, SpecificWeight specificWeight) - { - return new ForcePerLength(area.SquareMeters * specificWeight.NewtonsPerCubicMeter, ForcePerLengthUnit.NewtonPerMeter); - } - - /// Get from divided by . - public static Acceleration operator /(SpecificWeight specificWeight, Density density) - { - return new Acceleration(specificWeight.NewtonsPerCubicMeter / density.KilogramsPerCubicMeter, AccelerationUnit.MeterPerSecondSquared); - } - - /// Get from divided by . - public static Density operator /(SpecificWeight specific, Acceleration acceleration) - { - return new Density(specific.NewtonsPerCubicMeter / acceleration.MetersPerSecondSquared, DensityUnit.KilogramPerCubicMeter); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Speed.extra.cs b/UnitsNet/CustomCode/Quantities/Speed.extra.cs deleted file mode 100644 index b46031ab8d..0000000000 --- a/UnitsNet/CustomCode/Quantities/Speed.extra.cs +++ /dev/null @@ -1,76 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct Speed - { - /// Get from divided by . - public static Acceleration operator /(Speed speed, TimeSpan timeSpan) - { - return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / timeSpan.TotalSeconds); - } - - /// Get from times . - public static Length operator *(Speed speed, TimeSpan timeSpan) - { - return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); - } - - /// Get from times . - public static Length operator *(TimeSpan timeSpan, Speed speed) - { - return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); - } - - /// Get from divided by . - public static Acceleration operator /(Speed speed, Duration duration) - { - return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / duration.Seconds); - } - - /// Get from divided by . - public static Duration operator /(Speed speed, Acceleration acceleration) - { - return Duration.FromSeconds(speed.MetersPerSecond / acceleration.MetersPerSecondSquared); - } - - /// Get from times . - public static Length operator *(Speed speed, Duration duration) - { - return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); - } - - /// Get from times . - public static Length operator *(Duration duration, Speed speed) - { - return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); - } - - /// Get from times . - public static KinematicViscosity operator *(Speed speed, Length length) - { - return KinematicViscosity.FromSquareMetersPerSecond(length.Meters * speed.MetersPerSecond); - } - - /// Get from times . - public static SpecificEnergy operator *(Speed left, Speed right) - { - return SpecificEnergy.FromJoulesPerKilogram(left.MetersPerSecond * right.MetersPerSecond); - } - - /// Get from times . - public static MassFlux operator *(Speed speed, Density density) - { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(speed.MetersPerSecond * density.KilogramsPerCubicMeter); - } - - /// Get from times . - public static VolumeFlow operator *(Speed speed, Area area) - { - return VolumeFlow.FromCubicMetersPerSecond(speed.MetersPerSecond * area.SquareMeters); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/TemperatureChangeRate.extra.cs b/UnitsNet/CustomCode/Quantities/TemperatureChangeRate.extra.cs deleted file mode 100644 index 04f36df7bf..0000000000 --- a/UnitsNet/CustomCode/Quantities/TemperatureChangeRate.extra.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct TemperatureChangeRate - { - /// Get from times . - public static TemperatureDelta operator *(Duration left, TemperatureChangeRate right) => right * left; - - /// Get from times . - public static TemperatureDelta operator *(TemperatureChangeRate left, Duration right) - { - return TemperatureDelta.FromDegreesCelsius(left.DegreesCelsiusPerSecond * right.Seconds); - } - - - /// Get from times . - public static TemperatureDelta operator *(TimeSpan left, TemperatureChangeRate right) => right * left; - - /// Get from times . - public static TemperatureDelta operator *(TemperatureChangeRate left, TimeSpan right) - { - return TemperatureDelta.FromDegreesCelsius(left.DegreesCelsiusPerSecond * right.TotalSeconds); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs b/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs deleted file mode 100644 index e126f14d29..0000000000 --- a/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct TemperatureDelta - { - /// Get from divided by . - public static TemperatureGradient operator /(TemperatureDelta left, Length right) - { - return TemperatureGradient.FromKelvinsPerMeter(left.Kelvins / right.Meters); - } - - /// Get from times . - public static SpecificEnergy operator *(SpecificEntropy specificEntropy, TemperatureDelta temperatureDelta) - { - return SpecificEnergy.FromJoulesPerKilogram(specificEntropy.JoulesPerKilogramKelvin * temperatureDelta.Kelvins); - } - - /// Get from times . - public static SpecificEnergy operator *(TemperatureDelta temperatureDelta, SpecificEntropy specificEntropy) - { - return specificEntropy * temperatureDelta; - } - - /// Get from times . - public static Energy operator *(Entropy entropy, TemperatureDelta temperatureDelta) - { - return Energy.FromJoules(entropy.JoulesPerKelvin * temperatureDelta.Kelvins); - } - - /// Get from times . - public static Energy operator *(TemperatureDelta temperatureDelta, Entropy entropy) - { - return Energy.FromJoules(entropy.JoulesPerKelvin * temperatureDelta.Kelvins); - } - - /// Get a scalar from a multiplied by a . - public static double operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion cte) - { - return temperatureDelta.Kelvins * cte.PerKelvin; - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/TemperatureGradient.extra.cs b/UnitsNet/CustomCode/Quantities/TemperatureGradient.extra.cs deleted file mode 100644 index c6d5d087c7..0000000000 --- a/UnitsNet/CustomCode/Quantities/TemperatureGradient.extra.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct TemperatureGradient - { - /// Get from divided by . - public static Length operator /(TemperatureDelta left, TemperatureGradient right) - { - return Length.FromKilometers(left.Kelvins / right.DegreesCelciusPerKilometer); - } - - /// Get from times . - public static TemperatureDelta operator *(Length left, TemperatureGradient right) => right * left; - - /// Get from times . - public static TemperatureDelta operator *(TemperatureGradient left, Length right) - { - return TemperatureDelta.FromDegreesCelsius(left.DegreesCelciusPerKilometer * right.Kilometers); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Torque.extra.cs b/UnitsNet/CustomCode/Quantities/Torque.extra.cs deleted file mode 100644 index 26bd4f551b..0000000000 --- a/UnitsNet/CustomCode/Quantities/Torque.extra.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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. - -namespace UnitsNet -{ - public partial struct Torque - { - /// Get from times . - public static Force operator /(Torque torque, Length length) - { - return Force.FromNewtons(torque.NewtonMeters / length.Meters); - } - - /// Get from times . - public static Length operator /(Torque torque, Force force) - { - return Length.FromMeters(torque.NewtonMeters / force.Newtons); - } - - /// Get from times . - public static RotationalStiffness operator /(Torque torque, Angle angle) - { - return RotationalStiffness.FromNewtonMetersPerRadian(torque.NewtonMeters / angle.Radians); - } - - /// Get from times . - public static Angle operator /(Torque torque, RotationalStiffness rotationalStiffness) - { - return Angle.FromRadians(torque.NewtonMeters / rotationalStiffness.NewtonMetersPerRadian); - } - } -} diff --git a/UnitsNet/CustomCode/Quantities/Volume.extra.cs b/UnitsNet/CustomCode/Quantities/Volume.extra.cs index aab43915a4..88d6bf2a51 100644 --- a/UnitsNet/CustomCode/Quantities/Volume.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Volume.extra.cs @@ -7,30 +7,6 @@ namespace UnitsNet { public partial struct Volume { - /// Get from divided by . - public static Area operator /(Volume volume, Length length) - { - return Area.FromSquareMeters(volume.CubicMeters / length.Meters); - } - - /// Get from divided by . - public static Length operator /(Volume volume, Area area) - { - return Length.FromMeters(volume.CubicMeters / area.SquareMeters); - } - - /// Get from divided by . - public static VolumeFlow operator /(Volume volume, Duration duration) - { - return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / duration.Seconds); - } - - /// Get from divided by . - public static VolumeFlow operator /(Volume volume, TimeSpan timeSpan) - { - return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / timeSpan.TotalSeconds); - } - /// Get from divided by . public static TimeSpan operator /(Volume volume, VolumeFlow volumeFlow) { diff --git a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs index fed1b0ca30..205acf77e3 100644 --- a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs @@ -47,22 +47,5 @@ public static VolumeConcentration FromMolarity(Molarity molarity, Density compon } #endregion - - #region Operators - - /// Get from times the component . - public static MassConcentration operator *(VolumeConcentration volumeConcentration, Density componentDensity) - { - return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); - } - - /// Get from times the component . - public static MassConcentration operator *(Density componentDensity, VolumeConcentration volumeConcentration) - { - return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); - } - - #endregion - } } diff --git a/UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs b/UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs deleted file mode 100644 index 51e71e8180..0000000000 --- a/UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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; - -namespace UnitsNet -{ - public partial struct VolumeFlow - { - /// Get from times . - public static Volume operator *(VolumeFlow volumeFlow, TimeSpan timeSpan) - { - return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * timeSpan.TotalSeconds); - } - - /// Get from times . - public static Volume operator *(VolumeFlow volumeFlow, Duration duration) - { - return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * duration.Seconds); - } - - /// Get from divided by . - public static Speed operator /(VolumeFlow volumeFlow, Area area) - { - return Speed.FromMetersPerSecond(volumeFlow.CubicMetersPerSecond / area.SquareMeters); - } - - /// Get from divided by . - public static Area operator /(VolumeFlow volumeFlow, Speed speed) - { - return Area.FromSquareMeters(volumeFlow.CubicMetersPerSecond / speed.MetersPerSecond); - } - - /// Get from times . - public static MassFlow operator *(VolumeFlow volumeFlow, Density density) - { - return MassFlow.FromKilogramsPerSecond(volumeFlow.CubicMetersPerSecond * density.KilogramsPerCubicMeter); - } - - /// Get from times . - public static MassFlow operator *(Density density, VolumeFlow volumeFlow) - { - return MassFlow.FromKilogramsPerSecond(volumeFlow.CubicMetersPerSecond * density.KilogramsPerCubicMeter); - } - } -} diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index ba700ce0a6..725c643340 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,14 @@ namespace UnitsNet [DataContract] public readonly partial struct Acceleration : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -664,6 +675,52 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel #endregion + #region Relational Operators + + /// Get from * . + public static Force operator *(Acceleration acceleration, Mass mass) + { + return Force.FromNewtons(acceleration.MetersPerSecondSquared * mass.Kilograms); + } + + /// Get from / . + public static Jerk operator /(Acceleration acceleration, Duration duration) + { + return Jerk.FromMetersPerSecondCubed(acceleration.MetersPerSecondSquared / duration.Seconds); + } + + /// Get from * . + public static SpecificWeight operator *(Acceleration acceleration, Density density) + { + return SpecificWeight.FromNewtonsPerCubicMeter(acceleration.MetersPerSecondSquared * density.KilogramsPerCubicMeter); + } + + /// Get from * . + public static Speed operator *(Acceleration acceleration, Duration duration) + { + return Speed.FromMetersPerSecond(acceleration.MetersPerSecondSquared * duration.Seconds); + } + + /// Get from / . + public static Jerk operator /(Acceleration acceleration, TimeSpan timeSpan) + { + return Jerk.FromMetersPerSecondCubed(acceleration.MetersPerSecondSquared / timeSpan.TotalSeconds); + } + + /// Get from * . + public static Speed operator *(Acceleration acceleration, TimeSpan timeSpan) + { + return Speed.FromMetersPerSecond(acceleration.MetersPerSecondSquared * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Speed operator *(TimeSpan timeSpan, Acceleration acceleration) + { + return Speed.FromMetersPerSecond(timeSpan.TotalSeconds * acceleration.MetersPerSecondSquared); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 7c428ebd06..3dff1d8f94 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,11 @@ namespace UnitsNet [DataContract] public readonly partial struct AmountOfSubstance : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -718,6 +726,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun #endregion + #region Relational Operators + + /// Get from * . + public static Mass operator *(AmountOfSubstance amountOfSubstance, MolarMass molarMass) + { + return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); + } + + /// Get from / . + public static Molarity operator /(AmountOfSubstance amountOfSubstance, Volume volume) + { + return Molarity.FromMolesPerCubicMeter(amountOfSubstance.Moles / volume.CubicMeters); + } + + /// Get from / . + public static Volume operator /(AmountOfSubstance amountOfSubstance, Molarity molarity) + { + return Volume.FromCubicMeters(amountOfSubstance.Moles / molarity.MolesPerCubicMeter); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index e1e19da154..4761c4392e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,11 @@ namespace UnitsNet [DataContract] public readonly partial struct Angle : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -700,6 +708,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle #endregion + #region Relational Operators + + /// Get from / . + public static RotationalSpeed operator /(Angle angle, Duration duration) + { + return RotationalSpeed.FromRadiansPerSecond(angle.Radians / duration.Seconds); + } + + /// Get from * . + public static Torque operator *(Angle angle, RotationalStiffness rotationalStiffness) + { + return Torque.FromNewtonMeters(angle.Radians * rotationalStiffness.NewtonMetersPerRadian); + } + + /// Get from / . + public static RotationalSpeed operator /(Angle angle, TimeSpan timeSpan) + { + return RotationalSpeed.FromRadiansPerSecond(angle.Radians / timeSpan.TotalSeconds); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 6c0b4d2bb2..195f583d77 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,20 @@ namespace UnitsNet [DataContract] public readonly partial struct Area : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -664,6 +681,89 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU #endregion + #region Relational Operators + + /// Get from * . + public static Force operator *(Area area, Pressure pressure) + { + return Force.FromNewtons(area.SquareMeters * pressure.Pascals); + } + + /// Get from * . + public static ForcePerLength operator *(Area area, SpecificWeight specificWeight) + { + return ForcePerLength.FromNewtonsPerMeter(area.SquareMeters * specificWeight.NewtonsPerCubicMeter); + } + + /// Get from / . + public static Length operator /(Area area, Length length) + { + return Length.FromMeters(area.SquareMeters / length.Meters); + } + + /// Get from * . + public static LinearDensity operator *(Area area, Density density) + { + return LinearDensity.FromKilogramsPerMeter(area.SquareMeters * density.KilogramsPerCubicMeter); + } + + /// Get from * . + public static LuminousIntensity operator *(Area area, Luminance luminance) + { + return LuminousIntensity.FromCandela(area.SquareMeters * luminance.CandelasPerSquareMeter); + } + + /// Get from * . + public static Mass operator *(Area area, AreaDensity areaDensity) + { + return Mass.FromKilograms(area.SquareMeters * areaDensity.KilogramsPerSquareMeter); + } + + /// Get from * . + public static MassFlow operator *(Area area, MassFlux massFlux) + { + return MassFlow.FromGramsPerSecond(area.SquareMeters * massFlux.GramsPerSecondPerSquareMeter); + } + + /// Get from * . + public static Power operator *(Area area, HeatFlux heatFlux) + { + return Power.FromWatts(area.SquareMeters * heatFlux.WattsPerSquareMeter); + } + + /// Get from * . + public static Ratio operator *(Area area, ReciprocalArea reciprocalArea) + { + return Ratio.FromDecimalFractions(area.SquareMeters * reciprocalArea.InverseSquareMeters); + } + + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public ReciprocalArea Inverse() + { + return SquareMeters == 0.0 ? ReciprocalArea.Zero : ReciprocalArea.FromInverseSquareMeters(1 / SquareMeters); + } + + /// Get from * . + public static Torque operator *(Area area, ForcePerLength forcePerLength) + { + return Torque.FromNewtonMeters(area.SquareMeters * forcePerLength.NewtonsPerMeter); + } + + /// Get from * . + public static Volume operator *(Area area, Length length) + { + return Volume.FromCubicMeters(area.SquareMeters * length.Meters); + } + + /// Get from * . + public static VolumeFlow operator *(Area area, Speed speed) + { + return VolumeFlow.FromCubicMetersPerSecond(area.SquareMeters * speed.MetersPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index b1413377f3..29ad148ae0 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct AreaDensity : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -466,6 +472,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD #endregion + #region Relational Operators + + /// Get from * . + public static Mass operator *(AreaDensity areaDensity, Area area) + { + return Mass.FromKilograms(areaDensity.KilogramsPerSquareMeter * area.SquareMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 5e99d19640..a120b4caf0 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct AreaMomentOfInertia : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -520,6 +526,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM #endregion + #region Relational Operators + + /// Get from / . + public static Volume operator /(AreaMomentOfInertia areaMomentOfInertia, Length length) + { + return Volume.FromCubicMeters(areaMomentOfInertia.MetersToTheFourth / length.Meters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 9d44e789dd..e90e9e2e5f 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct BrakeSpecificFuelConsumption : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -466,6 +473,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake #endregion + #region Relational Operators + + /// Get from * . + public static double operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, SpecificEnergy specificEnergy) + { + return brakeSpecificFuelConsumption.KilogramsPerJoule * specificEnergy.JoulesPerKilogram; + } + + /// Get from * . + public static MassFlow operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, Power power) + { + return MassFlow.FromKilogramsPerSecond(brakeSpecificFuelConsumption.KilogramsPerJoule * (double)power.Watts); + } + + /// Get from / . + public static SpecificEnergy operator /(double value, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + { + return SpecificEnergy.FromJoulesPerKilogram(value / brakeSpecificFuelConsumption.KilogramsPerJoule); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index fb3f68cec8..f54b257578 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct CoefficientOfThermalExpansion : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -580,6 +586,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff #endregion + #region Relational Operators + + /// Get from * . + public static double operator *(CoefficientOfThermalExpansion coefficientOfThermalExpansion, TemperatureDelta temperatureDelta) + { + return coefficientOfThermalExpansion.PerKelvin * temperatureDelta.Kelvins; + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index d648a03d8f..423151009a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,15 @@ namespace UnitsNet [DataContract] public readonly partial struct Density : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -1423,6 +1435,52 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi #endregion + #region Relational Operators + + /// Get from * . + public static DynamicViscosity operator *(Density density, KinematicViscosity kinematicViscosity) + { + return DynamicViscosity.FromNewtonSecondsPerMeterSquared(density.KilogramsPerCubicMeter * kinematicViscosity.SquareMetersPerSecond); + } + + /// Get from * . + public static LinearDensity operator *(Density density, Area area) + { + return LinearDensity.FromKilogramsPerMeter(density.KilogramsPerCubicMeter * area.SquareMeters); + } + + /// Get from * . + public static Mass operator *(Density density, Volume volume) + { + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + } + + /// Get from * . + public static MassConcentration operator *(Density density, VolumeConcentration volumeConcentration) + { + return MassConcentration.FromKilogramsPerCubicMeter(density.KilogramsPerCubicMeter * volumeConcentration.DecimalFractions); + } + + /// Get from * . + public static MassFlow operator *(Density density, VolumeFlow volumeFlow) + { + return MassFlow.FromKilogramsPerSecond(density.KilogramsPerCubicMeter * volumeFlow.CubicMetersPerSecond); + } + + /// Get from * . + public static MassFlux operator *(Density density, Speed speed) + { + return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); + } + + /// Get from * . + public static SpecificWeight operator *(Density density, Acceleration acceleration) + { + return SpecificWeight.FromNewtonsPerCubicMeter(density.KilogramsPerCubicMeter * acceleration.MetersPerSecondSquared); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index b7d437df45..3d4ae1465e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,21 @@ namespace UnitsNet [DataContract] public readonly partial struct Duration : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -610,6 +628,88 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat #endregion + #region Relational Operators + + /// Get from * . + public static AmountOfSubstance operator *(Duration duration, MolarFlow molarFlow) + { + return AmountOfSubstance.FromKilomoles(duration.Seconds * molarFlow.KilomolesPerSecond); + } + + /// Get from * . + public static Angle operator *(Duration duration, RotationalSpeed rotationalSpeed) + { + return Angle.FromRadians(duration.Seconds * rotationalSpeed.RadiansPerSecond); + } + + /// Get from * . + public static Area operator *(Duration duration, KinematicViscosity kinematicViscosity) + { + return Area.FromSquareMeters(duration.Seconds * kinematicViscosity.SquareMetersPerSecond); + } + + /// Get from * . + public static ElectricCharge operator *(Duration duration, ElectricCurrent electricCurrent) + { + return ElectricCharge.FromAmpereHours(duration.Hours * electricCurrent.Amperes); + } + + /// Get from * . + public static ElectricCurrent operator *(Duration duration, ElectricCurrentGradient electricCurrentGradient) + { + return ElectricCurrent.FromAmperes(duration.Seconds * electricCurrentGradient.AmperesPerSecond); + } + + /// Get from * . + public static Energy operator *(Duration duration, Power power) + { + return Energy.FromJoules(duration.Seconds * (double)power.Watts); + } + + /// Get from * . + public static Force operator *(Duration duration, ForceChangeRate forceChangeRate) + { + return Force.FromNewtons(duration.Seconds * forceChangeRate.NewtonsPerSecond); + } + + /// Get from * . + public static Length operator *(Duration duration, Speed speed) + { + return Length.FromMeters(duration.Seconds * speed.MetersPerSecond); + } + + /// Get from * . + public static Mass operator *(Duration duration, MassFlow massFlow) + { + return Mass.FromKilograms(duration.Seconds * massFlow.KilogramsPerSecond); + } + + /// Get from * . + public static Pressure operator *(Duration duration, PressureChangeRate pressureChangeRate) + { + return Pressure.FromPascals(duration.Seconds * pressureChangeRate.PascalsPerSecond); + } + + /// Get from * . + public static Speed operator *(Duration duration, Acceleration acceleration) + { + return Speed.FromMetersPerSecond(duration.Seconds * acceleration.MetersPerSecondSquared); + } + + /// Get from * . + public static TemperatureDelta operator *(Duration duration, TemperatureChangeRate temperatureChangeRate) + { + return TemperatureDelta.FromDegreesCelsius(duration.Seconds * temperatureChangeRate.DegreesCelsiusPerSecond); + } + + /// Get from * . + public static Volume operator *(Duration duration, VolumeFlow volumeFlow) + { + return Volume.FromCubicMeters(duration.Seconds * volumeFlow.CubicMetersPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 8b9fec91e9..595cbeaad1 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,9 @@ namespace UnitsNet [DataContract] public readonly partial struct DynamicViscosity : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -595,6 +601,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam #endregion + #region Relational Operators + + /// Get from / . + public static KinematicViscosity operator /(DynamicViscosity dynamicViscosity, Density density) + { + return KinematicViscosity.FromSquareMetersPerSecond(dynamicViscosity.NewtonSecondsPerMeterSquared / density.KilogramsPerCubicMeter); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 7882ac8960..ba31a49c68 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,12 @@ namespace UnitsNet [DataContract] public readonly partial struct ElectricCharge : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -613,6 +622,34 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #endregion + #region Relational Operators + + /// Get from / . + public static Duration operator /(ElectricCharge electricCharge, ElectricCurrent electricCurrent) + { + return Duration.FromHours(electricCharge.AmpereHours / electricCurrent.Amperes); + } + + /// Get from / . + public static ElectricCurrent operator /(ElectricCharge electricCharge, Duration duration) + { + return ElectricCurrent.FromAmperes(electricCharge.AmpereHours / duration.Hours); + } + + /// Get from * . + public static Energy operator *(ElectricCharge electricCharge, ElectricPotential electricPotential) + { + return Energy.FromJoules(electricCharge.Coulombs * electricPotential.Volts); + } + + /// Get from / . + public static ElectricCurrent operator /(ElectricCharge electricCharge, TimeSpan timeSpan) + { + return ElectricCurrent.FromAmperes(electricCharge.AmpereHours / timeSpan.TotalHours); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 09df006af7..deb46b99fd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -523,6 +523,17 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #endregion + #region Relational Operators + + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public ElectricResistivity Inverse() + { + return SiemensPerMeter == 0.0 ? ElectricResistivity.Zero : ElectricResistivity.FromOhmMeters(1 / SiemensPerMeter); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 80e95ee4ba..57c083f1c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,14 @@ namespace UnitsNet [DataContract] public readonly partial struct ElectricCurrent : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -574,6 +585,52 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #endregion + #region Relational Operators + + /// Get from * . + public static ElectricCharge operator *(ElectricCurrent electricCurrent, Duration duration) + { + return ElectricCharge.FromAmpereHours(electricCurrent.Amperes * duration.Hours); + } + + /// Get from / . + public static ElectricCurrentGradient operator /(ElectricCurrent electricCurrent, Duration duration) + { + return ElectricCurrentGradient.FromAmperesPerSecond(electricCurrent.Amperes / duration.Seconds); + } + + /// Get from * . + public static ElectricPotential operator *(ElectricCurrent electricCurrent, ElectricResistance electricResistance) + { + return ElectricPotential.FromVolts(electricCurrent.Amperes * electricResistance.Ohms); + } + + /// Get from * . + public static Power operator *(ElectricCurrent electricCurrent, ElectricPotential electricPotential) + { + return Power.FromWatts(electricCurrent.Amperes * electricPotential.Volts); + } + + /// Get from * . + public static ElectricCharge operator *(ElectricCurrent electricCurrent, TimeSpan timeSpan) + { + return ElectricCharge.FromAmpereHours(electricCurrent.Amperes * timeSpan.TotalHours); + } + + /// Get from * . + public static ElectricCharge operator *(TimeSpan timeSpan, ElectricCurrent electricCurrent) + { + return ElectricCharge.FromAmpereHours(timeSpan.TotalHours * electricCurrent.Amperes); + } + + /// Get from / . + public static ElectricCurrentGradient operator /(ElectricCurrent electricCurrent, TimeSpan timeSpan) + { + return ElectricCurrentGradient.FromAmperesPerSecond(electricCurrent.Amperes / timeSpan.TotalSeconds); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 044d4ad6d7..7617d04940 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct ElectricCurrentGradient : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -538,6 +545,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #endregion + #region Relational Operators + + /// Get from * . + public static ElectricCurrent operator *(ElectricCurrentGradient electricCurrentGradient, Duration duration) + { + return ElectricCurrent.FromAmperes(electricCurrentGradient.AmperesPerSecond * duration.Seconds); + } + + /// Get from * . + public static ElectricCurrent operator *(ElectricCurrentGradient electricCurrentGradient, TimeSpan timeSpan) + { + return ElectricCurrent.FromAmperes(electricCurrentGradient.AmperesPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static ElectricCurrent operator *(TimeSpan timeSpan, ElectricCurrentGradient electricCurrentGradient) + { + return ElectricCurrent.FromAmperes(timeSpan.TotalSeconds * electricCurrentGradient.AmperesPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index bf4fd44d3f..04a4c8820a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,12 @@ namespace UnitsNet [DataContract] public readonly partial struct ElectricPotential : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -520,6 +529,34 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #endregion + #region Relational Operators + + /// Get from / . + public static ElectricCurrent operator /(ElectricPotential electricPotential, ElectricResistance electricResistance) + { + return ElectricCurrent.FromAmperes(electricPotential.Volts / electricResistance.Ohms); + } + + /// Get from / . + public static ElectricResistance operator /(ElectricPotential electricPotential, ElectricCurrent electricCurrent) + { + return ElectricResistance.FromOhms(electricPotential.Volts / electricCurrent.Amperes); + } + + /// Get from * . + public static Energy operator *(ElectricPotential electricPotential, ElectricCharge electricCharge) + { + return Energy.FromJoules(electricPotential.Volts * electricCharge.Coulombs); + } + + /// Get from * . + public static Power operator *(ElectricPotential electricPotential, ElectricCurrent electricCurrent) + { + return Power.FromWatts(electricPotential.Volts * electricCurrent.Amperes); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index b91c8e0b72..c1b4e12e8e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct ElectricResistance : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -538,6 +544,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #endregion + #region Relational Operators + + /// Get from * . + public static ElectricPotential operator *(ElectricResistance electricResistance, ElectricCurrent electricCurrent) + { + return ElectricPotential.FromVolts(electricResistance.Ohms * electricCurrent.Amperes); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 3332a834ad..89193b7021 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -667,6 +667,17 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #endregion + #region Relational Operators + + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public ElectricConductivity Inverse() + { + return OhmMeters == 0.0 ? ElectricConductivity.Zero : ElectricConductivity.FromSiemensPerMeter(1 / OhmMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 151a2621ee..673d0ca5f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,18 @@ namespace UnitsNet [DataContract] public readonly partial struct Energy : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -1132,6 +1147,70 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ #endregion + #region Relational Operators + + /// Get from / . + public static Duration operator /(Energy energy, Power power) + { + return Duration.FromSeconds(energy.Joules / (double)power.Watts); + } + + /// Get from / . + public static ElectricCharge operator /(Energy energy, ElectricPotential electricPotential) + { + return ElectricCharge.FromCoulombs(energy.Joules / electricPotential.Volts); + } + + /// Get from / . + public static ElectricPotential operator /(Energy energy, ElectricCharge electricCharge) + { + return ElectricPotential.FromVolts(energy.Joules / electricCharge.Coulombs); + } + + /// Get from / . + public static Entropy operator /(Energy energy, TemperatureDelta temperatureDelta) + { + return Entropy.FromJoulesPerKelvin(energy.Joules / temperatureDelta.Kelvins); + } + + /// Get from / . + public static Mass operator /(Energy energy, SpecificEnergy specificEnergy) + { + return Mass.FromKilograms(energy.Joules / specificEnergy.JoulesPerKilogram); + } + + /// Get from * . + public static Power operator *(Energy energy, Frequency frequency) + { + return Power.FromWatts(energy.Joules * frequency.PerSecond); + } + + /// Get from / . + public static Power operator /(Energy energy, Duration duration) + { + return Power.FromWatts(energy.Joules / duration.Seconds); + } + + /// Get from / . + public static SpecificEnergy operator /(Energy energy, Mass mass) + { + return SpecificEnergy.FromJoulesPerKilogram(energy.Joules / mass.Kilograms); + } + + /// Get from / . + public static TemperatureDelta operator /(Energy energy, Entropy entropy) + { + return TemperatureDelta.FromKelvins(energy.Joules / entropy.JoulesPerKelvin); + } + + /// Get from / . + public static Power operator /(Energy energy, TimeSpan timeSpan) + { + return Power.FromWatts(energy.Joules / timeSpan.TotalSeconds); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 6c9cebbdc1..26b61f515a 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct EnergyDensity : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -628,6 +634,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ #endregion + #region Relational Operators + + /// Get from * . + public static Energy operator *(EnergyDensity energyDensity, Volume volume) + { + return Energy.FromJoules(energyDensity.JoulesPerCubicMeter * volume.CubicMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index df5ec29e4d..310a82e47f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct Entropy : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -538,6 +545,22 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro #endregion + #region Relational Operators + + /// Get from * . + public static Energy operator *(Entropy entropy, TemperatureDelta temperatureDelta) + { + return Energy.FromJoules(entropy.JoulesPerKelvin * temperatureDelta.Kelvins); + } + + /// Get from / . + public static SpecificEntropy operator /(Entropy entropy, Mass mass) + { + return SpecificEntropy.FromJoulesPerKilogramKelvin(entropy.JoulesPerKelvin / mass.Kilograms); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index fe8fa8ae48..2cd32df359 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,18 @@ namespace UnitsNet [DataContract] public readonly partial struct Force : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -682,6 +697,70 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #endregion + #region Relational Operators + + /// Get from / . + public static Acceleration operator /(Force force, Mass mass) + { + return Acceleration.FromMetersPerSecondSquared(force.Newtons / mass.Kilograms); + } + + /// Get from / . + public static Duration operator /(Force force, ForceChangeRate forceChangeRate) + { + return Duration.FromSeconds(force.Newtons / forceChangeRate.NewtonsPerSecond); + } + + /// Get from * . + public static ForcePerLength operator *(Force force, ReciprocalLength reciprocalLength) + { + return ForcePerLength.FromNewtonsPerMeter(force.Newtons * reciprocalLength.InverseMeters); + } + + /// Get from / . + public static ForcePerLength operator /(Force force, Length length) + { + return ForcePerLength.FromNewtonsPerMeter(force.Newtons / length.Meters); + } + + /// Get from / . + public static Length operator /(Force force, ForcePerLength forcePerLength) + { + return Length.FromMeters(force.Newtons / forcePerLength.NewtonsPerMeter); + } + + /// Get from / . + public static Mass operator /(Force force, Acceleration acceleration) + { + return Mass.FromKilograms(force.Newtons / acceleration.MetersPerSecondSquared); + } + + /// Get from * . + public static Power operator *(Force force, Speed speed) + { + return Power.FromWatts(force.Newtons * speed.MetersPerSecond); + } + + /// Get from * . + public static Pressure operator *(Force force, ReciprocalArea reciprocalArea) + { + return Pressure.FromNewtonsPerSquareMeter(force.Newtons * reciprocalArea.InverseSquareMeters); + } + + /// Get from / . + public static Pressure operator /(Force force, Area area) + { + return Pressure.FromPascals(force.Newtons / area.SquareMeters); + } + + /// Get from * . + public static Torque operator *(Force force, Length length) + { + return Torque.FromNewtonMeters(force.Newtons * length.Meters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index ed92f8f384..a6e1e5b012 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct ForceChangeRate : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -682,6 +689,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #endregion + #region Relational Operators + + /// Get from * . + public static Force operator *(ForceChangeRate forceChangeRate, Duration duration) + { + return Force.FromNewtons(forceChangeRate.NewtonsPerSecond * duration.Seconds); + } + + /// Get from * . + public static Force operator *(ForceChangeRate forceChangeRate, TimeSpan timeSpan) + { + return Force.FromNewtons(forceChangeRate.NewtonsPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Force operator *(TimeSpan timeSpan, ForceChangeRate forceChangeRate) + { + return Force.FromNewtons(timeSpan.TotalSeconds * forceChangeRate.NewtonsPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 73654c7222..a12fcec880 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,13 @@ namespace UnitsNet [DataContract] public readonly partial struct ForcePerLength : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -1096,6 +1106,40 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #endregion + #region Relational Operators + + /// Get from * . + public static Force operator *(ForcePerLength forcePerLength, Length length) + { + return Force.FromNewtons(forcePerLength.NewtonsPerMeter * length.Meters); + } + + /// Get from / . + public static Force operator /(ForcePerLength forcePerLength, ReciprocalLength reciprocalLength) + { + return Force.FromNewtons(forcePerLength.NewtonsPerMeter / reciprocalLength.InverseMeters); + } + + /// Get from * . + public static Pressure operator *(ForcePerLength forcePerLength, ReciprocalLength reciprocalLength) + { + return Pressure.FromNewtonsPerSquareMeter(forcePerLength.NewtonsPerMeter * reciprocalLength.InverseMeters); + } + + /// Get from / . + public static Pressure operator /(ForcePerLength forcePerLength, Length length) + { + return Pressure.FromNewtonsPerSquareMeter(forcePerLength.NewtonsPerMeter / length.Meters); + } + + /// Get from * . + public static Torque operator *(ForcePerLength forcePerLength, Area area) + { + return Torque.FromNewtonMeters(forcePerLength.NewtonsPerMeter * area.SquareMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 70b75a26cb..424ad268cb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct Frequency : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -646,6 +652,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ #endregion + #region Relational Operators + + /// Get from * . + public static Power operator *(Frequency frequency, Energy energy) + { + return Power.FromWatts(frequency.PerSecond * energy.Joules); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index d0e2dac5e2..52133329b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct HeatFlux : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -736,6 +742,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF #endregion + #region Relational Operators + + /// Get from * . + public static Power operator *(HeatFlux heatFlux, Area area) + { + return Power.FromWatts(heatFlux.WattsPerSquareMeter * area.SquareMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index b278c98a98..71eed52ba8 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,12 @@ namespace UnitsNet [DataContract] public readonly partial struct KinematicViscosity : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -577,6 +586,40 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem #endregion + #region Relational Operators + + /// Get from * . + public static Area operator *(KinematicViscosity kinematicViscosity, Duration duration) + { + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); + } + + /// Get from * . + public static DynamicViscosity operator *(KinematicViscosity kinematicViscosity, Density density) + { + return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); + } + + /// Get from / . + public static Speed operator /(KinematicViscosity kinematicViscosity, Length length) + { + return Speed.FromMetersPerSecond(kinematicViscosity.SquareMetersPerSecond / length.Meters); + } + + /// Get from * . + public static Area operator *(KinematicViscosity kinematicViscosity, TimeSpan timeSpan) + { + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Area operator *(TimeSpan timeSpan, KinematicViscosity kinematicViscosity) + { + return Area.FromSquareMeters(timeSpan.TotalSeconds * kinematicViscosity.SquareMetersPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 56eb003acf..e0e2fc0314 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,20 @@ namespace UnitsNet [DataContract] public readonly partial struct Length : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -1168,6 +1185,89 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt #endregion + #region Relational Operators + + /// Get from * . + public static Area operator *(Length left, Length right) + { + return Area.FromSquareMeters(left.Meters * right.Meters); + } + + /// Get from / . + public static Duration operator /(Length length, Speed speed) + { + return Duration.FromSeconds(length.Meters / speed.MetersPerSecond); + } + + /// Get from * . + public static Force operator *(Length length, ForcePerLength forcePerLength) + { + return Force.FromNewtons(length.Meters * forcePerLength.NewtonsPerMeter); + } + + /// Get from * . + public static KinematicViscosity operator *(Length length, Speed speed) + { + return KinematicViscosity.FromSquareMetersPerSecond(length.Meters * speed.MetersPerSecond); + } + + /// Get from * . + public static Mass operator *(Length length, LinearDensity linearDensity) + { + return Mass.FromKilograms(length.Meters * linearDensity.KilogramsPerMeter); + } + + /// Get from * . + public static Pressure operator *(Length length, SpecificWeight specificWeight) + { + return Pressure.FromPascals(length.Meters * specificWeight.NewtonsPerCubicMeter); + } + + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public ReciprocalLength Inverse() + { + return Meters == 0.0 ? ReciprocalLength.Zero : ReciprocalLength.FromInverseMeters(1 / Meters); + } + + /// Get from * . + public static RotationalStiffness operator *(Length length, RotationalStiffnessPerLength rotationalStiffnessPerLength) + { + return RotationalStiffness.FromNewtonMetersPerRadian(length.Meters * rotationalStiffnessPerLength.NewtonMetersPerRadianPerMeter); + } + + /// Get from / . + public static Speed operator /(Length length, Duration duration) + { + return Speed.FromMetersPerSecond(length.Meters / duration.Seconds); + } + + /// Get from * . + public static TemperatureDelta operator *(Length length, TemperatureGradient temperatureGradient) + { + return TemperatureDelta.FromDegreesCelsius(length.Kilometers * temperatureGradient.DegreesCelciusPerKilometer); + } + + /// Get from * . + public static Torque operator *(Length length, Force force) + { + return Torque.FromNewtonMeters(length.Meters * force.Newtons); + } + + /// Get from * . + public static Volume operator *(Length length, Area area) + { + return Volume.FromCubicMeters(length.Meters * area.SquareMeters); + } + + /// Get from / . + public static Speed operator /(Length length, TimeSpan timeSpan) + { + return Speed.FromMetersPerSecond(length.Meters / timeSpan.TotalSeconds); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index f5c9f76ec8..c4da627aa7 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,11 @@ namespace UnitsNet [DataContract] public readonly partial struct LinearDensity : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -667,6 +675,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea #endregion + #region Relational Operators + + /// Get from / . + public static Area operator /(LinearDensity linearDensity, Density density) + { + return Area.FromSquareMeters(linearDensity.KilogramsPerMeter / density.KilogramsPerCubicMeter); + } + + /// Get from / . + public static Density operator /(LinearDensity linearDensity, Area area) + { + return Density.FromKilogramsPerCubicMeter(linearDensity.KilogramsPerMeter / area.SquareMeters); + } + + /// Get from * . + public static Mass operator *(LinearDensity linearDensity, Length length) + { + return Mass.FromKilograms(linearDensity.KilogramsPerMeter * length.Meters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index de6be7a16f..879d452115 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,9 @@ namespace UnitsNet [DataContract] public readonly partial struct Luminance : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -595,6 +601,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #endregion + #region Relational Operators + + /// Get from * . + public static LuminousIntensity operator *(Luminance luminance, Area area) + { + return LuminousIntensity.FromCandela(luminance.CandelasPerSquareMeter * area.SquareMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index f01aba9310..09735d275e 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,10 @@ namespace UnitsNet [DataContract] public readonly partial struct LuminousIntensity : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -433,6 +440,22 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #endregion + #region Relational Operators + + /// Get from / . + public static Area operator /(LuminousIntensity luminousIntensity, Luminance luminance) + { + return Area.FromSquareMeters(luminousIntensity.Candela / luminance.CandelasPerSquareMeter); + } + + /// Get from / . + public static Luminance operator /(LuminousIntensity luminousIntensity, Area area) + { + return Luminance.FromCandelasPerSquareMeter(luminousIntensity.Candela / area.SquareMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index fc866ba991..2d7fb4290b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,23 @@ namespace UnitsNet [DataContract] public readonly partial struct Mass : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -898,6 +918,100 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU #endregion + #region Relational Operators + + /// Get from / . + public static AmountOfSubstance operator /(Mass mass, MolarMass molarMass) + { + return AmountOfSubstance.FromMoles(mass.Kilograms / molarMass.KilogramsPerMole); + } + + /// Get from / . + public static Area operator /(Mass mass, AreaDensity areaDensity) + { + return Area.FromSquareMeters(mass.Kilograms / areaDensity.KilogramsPerSquareMeter); + } + + /// Get from / . + public static AreaDensity operator /(Mass mass, Area area) + { + return AreaDensity.FromKilogramsPerSquareMeter(mass.Kilograms / area.SquareMeters); + } + + /// Get from / . + public static Density operator /(Mass mass, Volume volume) + { + return Density.FromKilogramsPerCubicMeter(mass.Kilograms / volume.CubicMeters); + } + + /// Get from * . + public static Energy operator *(Mass mass, SpecificEnergy specificEnergy) + { + return Energy.FromJoules(mass.Kilograms * specificEnergy.JoulesPerKilogram); + } + + /// Get from * . + public static Entropy operator *(Mass mass, SpecificEntropy specificEntropy) + { + return Entropy.FromJoulesPerKelvin(mass.Kilograms * specificEntropy.JoulesPerKilogramKelvin); + } + + /// Get from * . + public static Force operator *(Mass mass, Acceleration acceleration) + { + return Force.FromNewtons(mass.Kilograms * acceleration.MetersPerSecondSquared); + } + + /// Get from / . + public static Length operator /(Mass mass, LinearDensity linearDensity) + { + return Length.FromMeters(mass.Kilograms / linearDensity.KilogramsPerMeter); + } + + /// Get from / . + public static LinearDensity operator /(Mass mass, Length length) + { + return LinearDensity.FromKilogramsPerMeter(mass.Kilograms / length.Meters); + } + + /// Get from / . + public static Mass operator /(Mass mass, MassFraction massFraction) + { + return Mass.FromKilograms(mass.Kilograms / massFraction.DecimalFractions); + } + + /// Get from * . + public static Mass operator *(Mass mass, MassFraction massFraction) + { + return Mass.FromKilograms(mass.Kilograms * massFraction.DecimalFractions); + } + + /// Get from / . + public static MassFlow operator /(Mass mass, Duration duration) + { + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / duration.Seconds); + } + + /// Get from / . + public static Volume operator /(Mass mass, Density density) + { + return Volume.FromCubicMeters(mass.Kilograms / density.KilogramsPerCubicMeter); + } + + /// Get from * . + public static Volume operator *(Mass mass, SpecificVolume specificVolume) + { + return Volume.FromCubicMeters(mass.Kilograms * specificVolume.CubicMetersPerKilogram); + } + + /// Get from / . + public static MassFlow operator /(Mass mass, TimeSpan timeSpan) + { + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / timeSpan.TotalSeconds); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index aabfd7f1d6..090cec7288 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,11 @@ namespace UnitsNet [DataContract] public readonly partial struct MassConcentration : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -1297,6 +1305,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC #endregion + #region Relational Operators + + /// Get from * . + public static Mass operator *(MassConcentration massConcentration, Volume volume) + { + return Mass.FromKilograms(massConcentration.KilogramsPerCubicMeter * volume.CubicMeters); + } + + /// Get from / . + public static Molarity operator /(MassConcentration massConcentration, MolarMass molarMass) + { + return Molarity.FromMolesPerCubicMeter(massConcentration.GramsPerCubicMeter / molarMass.GramsPerMole); + } + + /// Get from / . + public static VolumeConcentration operator /(MassConcentration massConcentration, Density density) + { + return VolumeConcentration.FromDecimalFractions(massConcentration.KilogramsPerCubicMeter / density.KilogramsPerCubicMeter); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 726589a06d..1d9487240c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,17 @@ namespace UnitsNet [DataContract] public readonly partial struct MassFlow : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -1006,6 +1020,70 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #endregion + #region Relational Operators + + /// Get from / . + public static Area operator /(MassFlow massFlow, MassFlux massFlux) + { + return Area.FromSquareMeters(massFlow.KilogramsPerSecond / massFlux.KilogramsPerSecondPerSquareMeter); + } + + /// Get from / . + public static BrakeSpecificFuelConsumption operator /(MassFlow massFlow, Power power) + { + return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / (double)power.Watts); + } + + /// Get from / . + public static Density operator /(MassFlow massFlow, VolumeFlow volumeFlow) + { + return Density.FromKilogramsPerCubicMeter(massFlow.KilogramsPerSecond / volumeFlow.CubicMetersPerSecond); + } + + /// Get from * . + public static Mass operator *(MassFlow massFlow, Duration duration) + { + return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); + } + + /// Get from / . + public static MassFlux operator /(MassFlow massFlow, Area area) + { + return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); + } + + /// Get from / . + public static Power operator /(MassFlow massFlow, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + { + return Power.FromWatts(massFlow.KilogramsPerSecond / brakeSpecificFuelConsumption.KilogramsPerJoule); + } + + /// Get from * . + public static Power operator *(MassFlow massFlow, SpecificEnergy specificEnergy) + { + return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); + } + + /// Get from / . + public static VolumeFlow operator /(MassFlow massFlow, Density density) + { + return VolumeFlow.FromCubicMetersPerSecond(massFlow.KilogramsPerSecond / density.KilogramsPerCubicMeter); + } + + /// Get from * . + public static Mass operator *(MassFlow massFlow, TimeSpan timeSpan) + { + return Mass.FromKilograms(massFlow.KilogramsPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Mass operator *(TimeSpan timeSpan, MassFlow massFlow) + { + return Mass.FromKilograms(timeSpan.TotalSeconds * massFlow.KilogramsPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 2feb33ed5b..bc68c04747 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,11 @@ namespace UnitsNet [DataContract] public readonly partial struct MassFlux : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -628,6 +636,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #endregion + #region Relational Operators + + /// Get from / . + public static Density operator /(MassFlux massFlux, Speed speed) + { + return Density.FromKilogramsPerCubicMeter(massFlux.KilogramsPerSecondPerSquareMeter / speed.MetersPerSecond); + } + + /// Get from * . + public static MassFlow operator *(MassFlux massFlux, Area area) + { + return MassFlow.FromGramsPerSecond(massFlux.GramsPerSecondPerSquareMeter * area.SquareMeters); + } + + /// Get from / . + public static Speed operator /(MassFlux massFlux, Density density) + { + return Speed.FromMetersPerSecond(massFlux.KilogramsPerSecondPerSquareMeter / density.KilogramsPerCubicMeter); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 074b9bd8fa..3095de01bf 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,9 @@ namespace UnitsNet [DataContract] public readonly partial struct MassFraction : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -847,6 +853,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #endregion + #region Relational Operators + + /// Get from * . + public static Mass operator *(MassFraction massFraction, Mass mass) + { + return Mass.FromKilograms(massFraction.DecimalFractions * mass.Kilograms); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index ce9a381c2e..6a66d0c379 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,12 @@ namespace UnitsNet [DataContract] public readonly partial struct MolarFlow : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -574,6 +583,40 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #endregion + #region Relational Operators + + /// Get from * . + public static AmountOfSubstance operator *(MolarFlow molarFlow, Duration duration) + { + return AmountOfSubstance.FromKilomoles(molarFlow.KilomolesPerSecond * duration.Seconds); + } + + /// Get from * . + public static MassFlow operator *(MolarFlow molarFlow, MolarMass molarMass) + { + return MassFlow.FromKilogramsPerSecond(molarFlow.KilomolesPerSecond * molarMass.KilogramsPerKilomole); + } + + /// Get from / . + public static VolumeFlow operator /(MolarFlow molarFlow, Molarity molarity) + { + return VolumeFlow.FromCubicMetersPerSecond(molarFlow.MolesPerSecond / molarity.MolesPerCubicMeter); + } + + /// Get from * . + public static AmountOfSubstance operator *(MolarFlow molarFlow, TimeSpan timeSpan) + { + return AmountOfSubstance.FromKilomoles(molarFlow.KilomolesPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static AmountOfSubstance operator *(TimeSpan timeSpan, MolarFlow molarFlow) + { + return AmountOfSubstance.FromKilomoles(timeSpan.TotalSeconds * molarFlow.KilomolesPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 8b72eb0323..3e29004ac2 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,11 @@ namespace UnitsNet [DataContract] public readonly partial struct MolarMass : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -646,6 +654,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #endregion + #region Relational Operators + + /// Get from * . + public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) + { + return Mass.FromGrams(molarMass.GramsPerMole * amountOfSubstance.Moles); + } + + /// Get from * . + public static MassConcentration operator *(MolarMass molarMass, Molarity molarity) + { + return MassConcentration.FromGramsPerCubicMeter(molarMass.GramsPerMole * molarity.MolesPerCubicMeter); + } + + /// Get from * . + public static MassFlow operator *(MolarMass molarMass, MolarFlow molarFlow) + { + return MassFlow.FromKilogramsPerSecond(molarMass.KilogramsPerKilomole * molarFlow.KilomolesPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 4814b4fdac..478de5bb67 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,10 @@ namespace UnitsNet [DataContract] public readonly partial struct Molarity : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -613,6 +620,22 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #endregion + #region Relational Operators + + /// Get from * . + public static MassConcentration operator *(Molarity molarity, MolarMass molarMass) + { + return MassConcentration.FromGramsPerCubicMeter(molarity.MolesPerCubicMeter * molarMass.GramsPerMole); + } + + /// Get from * . + public static Molarity operator *(Molarity molarity, VolumeConcentration volumeConcentration) + { + return Molarity.FromMolesPerCubicMeter(molarity.MolesPerCubicMeter * volumeConcentration.DecimalFractions); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 199ef43506..f074e2a525 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,20 @@ namespace UnitsNet [DataContract] public readonly partial struct Power : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IDecimalQuantity, IComparable, IComparable, @@ -881,6 +898,88 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #endregion + #region Relational Operators + + /// Get from / . + public static Area operator /(Power power, HeatFlux heatFlux) + { + return Area.FromSquareMeters((double)power.Watts / heatFlux.WattsPerSquareMeter); + } + + /// Get from / . + public static ElectricCurrent operator /(Power power, ElectricPotential electricPotential) + { + return ElectricCurrent.FromAmperes((double)power.Watts / electricPotential.Volts); + } + + /// Get from / . + public static ElectricPotential operator /(Power power, ElectricCurrent electricCurrent) + { + return ElectricPotential.FromVolts((double)power.Watts / electricCurrent.Amperes); + } + + /// Get from * . + public static Energy operator *(Power power, Duration duration) + { + return Energy.FromJoules((double)power.Watts * duration.Seconds); + } + + /// Get from / . + public static Force operator /(Power power, Speed speed) + { + return Force.FromNewtons((double)power.Watts / speed.MetersPerSecond); + } + + /// Get from / . + public static HeatFlux operator /(Power power, Area area) + { + return HeatFlux.FromWattsPerSquareMeter((double)power.Watts / area.SquareMeters); + } + + /// Get from * . + public static MassFlow operator *(Power power, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + { + return MassFlow.FromKilogramsPerSecond((double)power.Watts * brakeSpecificFuelConsumption.KilogramsPerJoule); + } + + /// Get from / . + public static MassFlow operator /(Power power, SpecificEnergy specificEnergy) + { + return MassFlow.FromKilogramsPerSecond((double)power.Watts / specificEnergy.JoulesPerKilogram); + } + + /// Get from / . + public static RotationalSpeed operator /(Power power, Torque torque) + { + return RotationalSpeed.FromRadiansPerSecond((double)power.Watts / torque.NewtonMeters); + } + + /// Get from / . + public static SpecificEnergy operator /(Power power, MassFlow massFlow) + { + return SpecificEnergy.FromJoulesPerKilogram((double)power.Watts / massFlow.KilogramsPerSecond); + } + + /// Get from / . + public static Torque operator /(Power power, RotationalSpeed rotationalSpeed) + { + return Torque.FromNewtonMeters((double)power.Watts / rotationalSpeed.RadiansPerSecond); + } + + /// Get from * . + public static Energy operator *(Power power, TimeSpan timeSpan) + { + return Energy.FromJoules((double)power.Watts * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Energy operator *(TimeSpan timeSpan, Power power) + { + return Energy.FromJoules(timeSpan.TotalSeconds * (double)power.Watts); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 25078e7698..777d8c544d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,15 @@ namespace UnitsNet [DataContract] public readonly partial struct Pressure : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -1294,6 +1306,52 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #endregion + #region Relational Operators + + /// Get from * . + public static Force operator *(Pressure pressure, Area area) + { + return Force.FromNewtons(pressure.Pascals * area.SquareMeters); + } + + /// Get from / . + public static Force operator /(Pressure pressure, ReciprocalArea reciprocalArea) + { + return Force.FromNewtons(pressure.Pascals / reciprocalArea.InverseSquareMeters); + } + + /// Get from / . + public static ForcePerLength operator /(Pressure pressure, ReciprocalLength reciprocalLength) + { + return ForcePerLength.FromNewtonsPerMeter(pressure.Pascals / reciprocalLength.InverseMeters); + } + + /// Get from / . + public static Length operator /(Pressure pressure, SpecificWeight specificWeight) + { + return Length.FromMeters(pressure.Pascals / specificWeight.NewtonsPerCubicMeter); + } + + /// Get from / . + public static PressureChangeRate operator /(Pressure pressure, Duration duration) + { + return PressureChangeRate.FromPascalsPerSecond(pressure.Pascals / duration.Seconds); + } + + /// Get from / . + public static SpecificWeight operator /(Pressure pressure, Length length) + { + return SpecificWeight.FromNewtonsPerCubicMeter(pressure.Pascals / length.Meters); + } + + /// Get from / . + public static PressureChangeRate operator /(Pressure pressure, TimeSpan timeSpan) + { + return PressureChangeRate.FromPascalsPerSecond(pressure.Pascals / timeSpan.TotalSeconds); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 9eba1a7ad0..a2a19ffac1 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct PressureChangeRate : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -736,6 +743,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #endregion + #region Relational Operators + + /// Get from * . + public static Pressure operator *(PressureChangeRate pressureChangeRate, Duration duration) + { + return Pressure.FromPascals(pressureChangeRate.PascalsPerSecond * duration.Seconds); + } + + /// Get from * . + public static Pressure operator *(PressureChangeRate pressureChangeRate, TimeSpan timeSpan) + { + return Pressure.FromPascals(pressureChangeRate.PascalsPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Pressure operator *(TimeSpan timeSpan, PressureChangeRate pressureChangeRate) + { + return Pressure.FromPascals(timeSpan.TotalSeconds * pressureChangeRate.PascalsPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 83edb0b0f8..95bb62799d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,11 @@ namespace UnitsNet [DataContract] public readonly partial struct ReciprocalArea : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -613,6 +621,35 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip #endregion + #region Relational Operators + + /// Get from * . + public static Pressure operator *(ReciprocalArea reciprocalArea, Force force) + { + return Pressure.FromNewtonsPerSquareMeter(reciprocalArea.InverseSquareMeters * force.Newtons); + } + + /// Get from * . + public static Ratio operator *(ReciprocalArea reciprocalArea, Area area) + { + return Ratio.FromDecimalFractions(reciprocalArea.InverseSquareMeters * area.SquareMeters); + } + + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public Area Inverse() + { + return InverseSquareMeters == 0.0 ? Area.Zero : Area.FromSquareMeters(1 / InverseSquareMeters); + } + + /// Get from / . + public static ReciprocalLength operator /(ReciprocalArea reciprocalArea, ReciprocalLength reciprocalLength) + { + return ReciprocalLength.FromInverseMeters(reciprocalArea.InverseSquareMeters / reciprocalLength.InverseMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 5757b2e3dc..105635debb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,12 @@ namespace UnitsNet [DataContract] public readonly partial struct ReciprocalLength : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -595,6 +604,41 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip #endregion + #region Relational Operators + + /// Get from * . + public static ForcePerLength operator *(ReciprocalLength reciprocalLength, Force force) + { + return ForcePerLength.FromNewtonsPerMeter(reciprocalLength.InverseMeters * force.Newtons); + } + + /// Get from / . + public static Length operator /(ReciprocalLength reciprocalLength, ReciprocalArea reciprocalArea) + { + return Length.FromMeters(reciprocalLength.InverseMeters / reciprocalArea.InverseSquareMeters); + } + + /// Get from * . + public static Pressure operator *(ReciprocalLength reciprocalLength, ForcePerLength forcePerLength) + { + return Pressure.FromNewtonsPerSquareMeter(reciprocalLength.InverseMeters * forcePerLength.NewtonsPerMeter); + } + + /// Get from * . + public static ReciprocalArea operator *(ReciprocalLength left, ReciprocalLength right) + { + return ReciprocalArea.FromInverseSquareMeters(left.InverseMeters * right.InverseMeters); + } + + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public Length Inverse() + { + return InverseMeters == 0.0 ? Length.Zero : Length.FromMeters(1 / InverseMeters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 3262386093..8501363750 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct RotationalSpeed : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -646,6 +653,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #endregion + #region Relational Operators + + /// Get from * . + public static Angle operator *(RotationalSpeed rotationalSpeed, Duration duration) + { + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); + } + + /// Get from * . + public static Angle operator *(RotationalSpeed rotationalSpeed, TimeSpan timeSpan) + { + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Angle operator *(TimeSpan timeSpan, RotationalSpeed rotationalSpeed) + { + return Angle.FromRadians(timeSpan.TotalSeconds * rotationalSpeed.RadiansPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 819a43022b..64f19e8372 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,11 @@ namespace UnitsNet [DataContract] public readonly partial struct RotationalStiffness : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -1006,6 +1014,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #endregion + #region Relational Operators + + /// Get from / . + public static Length operator /(RotationalStiffness rotationalStiffness, RotationalStiffnessPerLength rotationalStiffnessPerLength) + { + return Length.FromMeters(rotationalStiffness.NewtonMetersPerRadian / rotationalStiffnessPerLength.NewtonMetersPerRadianPerMeter); + } + + /// Get from / . + public static RotationalStiffnessPerLength operator /(RotationalStiffness rotationalStiffness, Length length) + { + return RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(rotationalStiffness.NewtonMetersPerRadian / length.Meters); + } + + /// Get from * . + public static Torque operator *(RotationalStiffness rotationalStiffness, Angle angle) + { + return Torque.FromNewtonMeters(rotationalStiffness.NewtonMetersPerRadian * angle.Radians); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 23a1cdafd5..e5a6418615 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct RotationalStiffnessPerLength : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -502,6 +508,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #endregion + #region Relational Operators + + /// Get from * . + public static RotationalStiffness operator *(RotationalStiffnessPerLength rotationalStiffnessPerLength, Length length) + { + return RotationalStiffness.FromNewtonMetersPerRadian(rotationalStiffnessPerLength.NewtonMetersPerRadianPerMeter * length.Meters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index ca1e69f93b..2c71ec1cbd 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,12 @@ namespace UnitsNet [DataContract] public readonly partial struct SpecificEnergy : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -955,6 +964,40 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #endregion + #region Relational Operators + + /// Get from / . + public static BrakeSpecificFuelConsumption operator /(double value, SpecificEnergy specificEnergy) + { + return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value / specificEnergy.JoulesPerKilogram); + } + + /// Get from * . + public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + { + return specificEnergy.JoulesPerKilogram * brakeSpecificFuelConsumption.KilogramsPerJoule; + } + + /// Get from * . + public static Energy operator *(SpecificEnergy specificEnergy, Mass mass) + { + return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); + } + + /// Get from * . + public static Power operator *(SpecificEnergy specificEnergy, MassFlow massFlow) + { + return Power.FromWatts(specificEnergy.JoulesPerKilogram * massFlow.KilogramsPerSecond); + } + + /// Get from / . + public static SpecificEntropy operator /(SpecificEnergy specificEnergy, TemperatureDelta temperatureDelta) + { + return SpecificEntropy.FromJoulesPerKilogramKelvin(specificEnergy.JoulesPerKilogram / temperatureDelta.Kelvins); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index a60c421170..c358ed82be 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct SpecificEntropy : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -574,6 +581,22 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #endregion + #region Relational Operators + + /// Get from * . + public static Entropy operator *(SpecificEntropy specificEntropy, Mass mass) + { + return Entropy.FromJoulesPerKelvin(specificEntropy.JoulesPerKilogramKelvin * mass.Kilograms); + } + + /// Get from * . + public static SpecificEnergy operator *(SpecificEntropy specificEntropy, TemperatureDelta temperatureDelta) + { + return SpecificEnergy.FromJoulesPerKilogram(specificEntropy.JoulesPerKilogramKelvin * temperatureDelta.Kelvins); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 9cfef5e88e..1236972c5d 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct SpecificVolume : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -466,6 +472,22 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #endregion + #region Relational Operators + + /// Get from / . + public static Density operator /(double value, SpecificVolume specificVolume) + { + return Density.FromKilogramsPerCubicMeter(value / specificVolume.CubicMetersPerKilogram); + } + + /// Get from * . + public static Volume operator *(SpecificVolume specificVolume, Mass mass) + { + return Volume.FromCubicMeters(specificVolume.CubicMetersPerKilogram * mass.Kilograms); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 8be1def8e8..2072c61c37 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,12 @@ namespace UnitsNet [DataContract] public readonly partial struct SpecificWeight : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -721,6 +730,34 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #endregion + #region Relational Operators + + /// Get from / . + public static Acceleration operator /(SpecificWeight specificWeight, Density density) + { + return Acceleration.FromMetersPerSecondSquared(specificWeight.NewtonsPerCubicMeter / density.KilogramsPerCubicMeter); + } + + /// Get from / . + public static Density operator /(SpecificWeight specificWeight, Acceleration acceleration) + { + return Density.FromKilogramsPerCubicMeter(specificWeight.NewtonsPerCubicMeter / acceleration.MetersPerSecondSquared); + } + + /// Get from * . + public static ForcePerLength operator *(SpecificWeight specificWeight, Area area) + { + return ForcePerLength.FromNewtonsPerMeter(specificWeight.NewtonsPerCubicMeter * area.SquareMeters); + } + + /// Get from * . + public static Pressure operator *(SpecificWeight specificWeight, Length length) + { + return Pressure.FromPascals(specificWeight.NewtonsPerCubicMeter * length.Meters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 07767638d6..4f20de6ffc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,18 @@ namespace UnitsNet [DataContract] public readonly partial struct Speed : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -1006,6 +1021,76 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed #endregion + #region Relational Operators + + /// Get from / . + public static Acceleration operator /(Speed speed, Duration duration) + { + return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / duration.Seconds); + } + + /// Get from / . + public static Duration operator /(Speed speed, Acceleration acceleration) + { + return Duration.FromSeconds(speed.MetersPerSecond / acceleration.MetersPerSecondSquared); + } + + /// Get from * . + public static KinematicViscosity operator *(Speed speed, Length length) + { + return KinematicViscosity.FromSquareMetersPerSecond(speed.MetersPerSecond * length.Meters); + } + + /// Get from * . + public static Length operator *(Speed speed, Duration duration) + { + return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); + } + + /// Get from * . + public static MassFlux operator *(Speed speed, Density density) + { + return MassFlux.FromKilogramsPerSecondPerSquareMeter(speed.MetersPerSecond * density.KilogramsPerCubicMeter); + } + + /// Get from * . + public static Power operator *(Speed speed, Force force) + { + return Power.FromWatts(speed.MetersPerSecond * force.Newtons); + } + + /// Get from * . + public static SpecificEnergy operator *(Speed left, Speed right) + { + return SpecificEnergy.FromJoulesPerKilogram(left.MetersPerSecond * right.MetersPerSecond); + } + + /// Get from * . + public static VolumeFlow operator *(Speed speed, Area area) + { + return VolumeFlow.FromCubicMetersPerSecond(speed.MetersPerSecond * area.SquareMeters); + } + + /// Get from / . + public static Acceleration operator /(Speed speed, TimeSpan timeSpan) + { + return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / timeSpan.TotalSeconds); + } + + /// Get from * . + public static Length operator *(Speed speed, TimeSpan timeSpan) + { + return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Length operator *(TimeSpan timeSpan, Speed speed) + { + return Length.FromMeters(timeSpan.TotalSeconds * speed.MetersPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index f0d3ffeec0..788e9ecc32 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,10 @@ namespace UnitsNet [DataContract] public readonly partial struct TemperatureChangeRate : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -592,6 +599,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #endregion + #region Relational Operators + + /// Get from * . + public static TemperatureDelta operator *(TemperatureChangeRate temperatureChangeRate, Duration duration) + { + return TemperatureDelta.FromDegreesCelsius(temperatureChangeRate.DegreesCelsiusPerSecond * duration.Seconds); + } + + /// Get from * . + public static TemperatureDelta operator *(TemperatureChangeRate temperatureChangeRate, TimeSpan timeSpan) + { + return TemperatureDelta.FromDegreesCelsius(temperatureChangeRate.DegreesCelsiusPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static TemperatureDelta operator *(TimeSpan timeSpan, TemperatureChangeRate temperatureChangeRate) + { + return TemperatureDelta.FromDegreesCelsius(timeSpan.TotalSeconds * temperatureChangeRate.DegreesCelsiusPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 00c73911da..3519803abd 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,13 @@ namespace UnitsNet [DataContract] public readonly partial struct TemperatureDelta : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -574,6 +584,40 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #endregion + #region Relational Operators + + /// Get from * . + public static double operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion coefficientOfThermalExpansion) + { + return temperatureDelta.Kelvins * coefficientOfThermalExpansion.PerKelvin; + } + + /// Get from * . + public static Energy operator *(TemperatureDelta temperatureDelta, Entropy entropy) + { + return Energy.FromJoules(temperatureDelta.Kelvins * entropy.JoulesPerKelvin); + } + + /// Get from / . + public static Length operator /(TemperatureDelta temperatureDelta, TemperatureGradient temperatureGradient) + { + return Length.FromKilometers(temperatureDelta.Kelvins / temperatureGradient.DegreesCelciusPerKilometer); + } + + /// Get from * . + public static SpecificEnergy operator *(TemperatureDelta temperatureDelta, SpecificEntropy specificEntropy) + { + return SpecificEnergy.FromJoulesPerKilogram(temperatureDelta.Kelvins * specificEntropy.JoulesPerKilogramKelvin); + } + + /// Get from / . + public static TemperatureGradient operator /(TemperatureDelta temperatureDelta, Length length) + { + return TemperatureGradient.FromKelvinsPerMeter(temperatureDelta.Kelvins / length.Meters); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index f62488e27f..181e98c115 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,9 @@ namespace UnitsNet [DataContract] public readonly partial struct TemperatureGradient : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -484,6 +490,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #endregion + #region Relational Operators + + /// Get from * . + public static TemperatureDelta operator *(TemperatureGradient temperatureGradient, Length length) + { + return TemperatureDelta.FromDegreesCelsius(temperatureGradient.DegreesCelciusPerKilometer * length.Kilometers); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index be55483305..7a4fd8c7af 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,12 @@ namespace UnitsNet [DataContract] public readonly partial struct Torque : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -862,6 +871,34 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu #endregion + #region Relational Operators + + /// Get from / . + public static Angle operator /(Torque torque, RotationalStiffness rotationalStiffness) + { + return Angle.FromRadians(torque.NewtonMeters / rotationalStiffness.NewtonMetersPerRadian); + } + + /// Get from / . + public static Force operator /(Torque torque, Length length) + { + return Force.FromNewtons(torque.NewtonMeters / length.Meters); + } + + /// Get from / . + public static Length operator /(Torque torque, Force force) + { + return Length.FromMeters(torque.NewtonMeters / force.Newtons); + } + + /// Get from / . + public static RotationalStiffness operator /(Torque torque, Angle angle) + { + return RotationalStiffness.FromNewtonMetersPerRadian(torque.NewtonMeters / angle.Radians); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index df86322da8..d3e788cfdc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,15 @@ namespace UnitsNet [DataContract] public readonly partial struct Volume : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, + IDivisionOperators, + IDivisionOperators, +#endif IComparable, IComparable, IConvertible, @@ -1384,6 +1396,52 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #endregion + #region Relational Operators + + /// Get from / . + public static Area operator /(Volume volume, Length length) + { + return Area.FromSquareMeters(volume.CubicMeters / length.Meters); + } + + /// Get from * . + public static Energy operator *(Volume volume, EnergyDensity energyDensity) + { + return Energy.FromJoules(volume.CubicMeters * energyDensity.JoulesPerCubicMeter); + } + + /// Get from / . + public static Length operator /(Volume volume, Area area) + { + return Length.FromMeters(volume.CubicMeters / area.SquareMeters); + } + + /// Get from * . + public static Mass operator *(Volume volume, Density density) + { + return Mass.FromKilograms(volume.CubicMeters * density.KilogramsPerCubicMeter); + } + + /// Get from * . + public static Mass operator *(Volume volume, MassConcentration massConcentration) + { + return Mass.FromKilograms(volume.CubicMeters * massConcentration.KilogramsPerCubicMeter); + } + + /// Get from / . + public static VolumeFlow operator /(Volume volume, Duration duration) + { + return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / duration.Seconds); + } + + /// Get from / . + public static VolumeFlow operator /(Volume volume, TimeSpan timeSpan) + { + return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / timeSpan.TotalSeconds); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 6233db1180..6f1fc9723f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -41,6 +44,10 @@ namespace UnitsNet [DataContract] public readonly partial struct VolumeConcentration : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -775,6 +782,22 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #endregion + #region Relational Operators + + /// Get from * . + public static MassConcentration operator *(VolumeConcentration volumeConcentration, Density density) + { + return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * density.KilogramsPerCubicMeter); + } + + /// Get from * . + public static Molarity operator *(VolumeConcentration volumeConcentration, Molarity molarity) + { + return Molarity.FromMolesPerCubicMeter(volumeConcentration.DecimalFractions * molarity.MolesPerCubicMeter); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 0842666310..f3eadae85c 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -21,6 +21,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if NET7_0_OR_GREATER +using System.Numerics; +#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -38,6 +41,13 @@ namespace UnitsNet [DataContract] public readonly partial struct VolumeFlow : IArithmeticQuantity, +#if NET7_0_OR_GREATER + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, +#endif IComparable, IComparable, IConvertible, @@ -1618,6 +1628,46 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #endregion + #region Relational Operators + + /// Get from / . + public static Area operator /(VolumeFlow volumeFlow, Speed speed) + { + return Area.FromSquareMeters(volumeFlow.CubicMetersPerSecond / speed.MetersPerSecond); + } + + /// Get from * . + public static MassFlow operator *(VolumeFlow volumeFlow, Density density) + { + return MassFlow.FromKilogramsPerSecond(volumeFlow.CubicMetersPerSecond * density.KilogramsPerCubicMeter); + } + + /// Get from / . + public static Speed operator /(VolumeFlow volumeFlow, Area area) + { + return Speed.FromMetersPerSecond(volumeFlow.CubicMetersPerSecond / area.SquareMeters); + } + + /// Get from * . + public static Volume operator *(VolumeFlow volumeFlow, Duration duration) + { + return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * duration.Seconds); + } + + /// Get from * . + public static Volume operator *(VolumeFlow volumeFlow, TimeSpan timeSpan) + { + return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Volume operator *(TimeSpan timeSpan, VolumeFlow volumeFlow) + { + return Volume.FromCubicMeters(timeSpan.TotalSeconds * volumeFlow.CubicMetersPerSecond); + } + + #endregion + #region Equality / IComparable /// Returns true if less or equal to. From c7918a30da3ccf7ad81b8d1fc8ac68c88b11d7a2 Mon Sep 17 00:00:00 2001 From: Muximize Date: Mon, 8 Jan 2024 12:28:19 +0100 Subject: [PATCH 04/12] Separate relation inference and application, add more comments --- CodeGen/Generators/QuantityRelationsParser.cs | 66 ++++++++----------- CodeGen/JsonTypes/QuantityRelation.cs | 8 --- CodeGen/JsonTypes/Unit.cs | 2 +- 3 files changed, 29 insertions(+), 47 deletions(-) diff --git a/CodeGen/Generators/QuantityRelationsParser.cs b/CodeGen/Generators/QuantityRelationsParser.cs index 4ec5bb62be..00664b036d 100644 --- a/CodeGen/Generators/QuantityRelationsParser.cs +++ b/CodeGen/Generators/QuantityRelationsParser.cs @@ -31,33 +31,34 @@ public static void ParseAndApplyRelations(string rootDir, Quantity[] quantities) var quantityDictionary = quantities.ToDictionary(q => q.Name, q => q); // Add double and 1 as pseudo-quantities to validate relations that use them. - var pseudoQuantity = new Quantity { Name = null!, Units = new[] { new Unit { SingularName = null! } } }; + var pseudoQuantity = new Quantity { Name = null!, Units = [new Unit { SingularName = null! }] }; quantityDictionary["double"] = pseudoQuantity with { Name = "double" }; quantityDictionary["1"] = pseudoQuantity with { Name = "1" }; var relations = ParseRelations(rootDir, quantityDictionary); - var timespanRelations = new List(); - foreach (var relation in relations) - { - if (relation.LeftQuantity.Name == "Duration") + // Because multiplication is commutative, we can infer the other operand order. + relations.AddRange(relations + .Where(r => r.Operator is "*" or "inverse" && r.LeftQuantity != r.RightQuantity) + .Select(r => r with { - timespanRelations.Add(relation with - { - LeftQuantity = new Quantity { Name = "TimeSpan" }, - }); - } - - if (relation.RightQuantity.Name == "Duration") - { - timespanRelations.Add(relation with - { - RightQuantity = new Quantity { Name = "TimeSpan" }, - }); - } - } - - relations.AddRange(timespanRelations); + LeftQuantity = r.RightQuantity, + LeftUnit = r.RightUnit, + RightQuantity = r.LeftQuantity, + RightUnit = r.LeftUnit, + }) + .ToList()); + + // We can infer TimeSpan relations from Duration relations. + var timeSpanQuantity = pseudoQuantity with { Name = "TimeSpan" }; + relations.AddRange(relations + .Where(r => r.LeftQuantity.Name is "Duration") + .Select(r => r with { LeftQuantity = timeSpanQuantity }) + .ToList()); + relations.AddRange(relations + .Where(r => r.RightQuantity.Name is "Duration") + .Select(r => r with { RightQuantity = timeSpanQuantity }) + .ToList()); foreach (var quantity in quantities) { @@ -67,24 +68,13 @@ public static void ParseAndApplyRelations(string rootDir, Quantity[] quantities) { if (relation.LeftQuantity == quantity) { + // The left operand of a relation is responsible for generating the operator. quantityRelations.Add(relation); - if (relation is { Operator: "*", RightQuantity.Name: "TimeSpan" or "double" }) - { - quantityRelations.Add(relation.Swapped()); - } } - - if (relation.RightQuantity == quantity) + else if (relation.RightQuantity == quantity && relation.LeftQuantity.Name is "double" or "TimeSpan") { - if (relation.Operator == "inverse" || relation.Operator == "*" && relation.LeftQuantity != relation.RightQuantity) - { - quantityRelations.Add(relation.Swapped()); - } - - if (relation is { Operator: "/", LeftQuantity.Name: "double" }) - { - quantityRelations.Add(relation); - } + // Because we cannot add generated operators to double or TimeSpan, we make the right operand responsible in this case. + quantityRelations.Add(relation); } } @@ -99,7 +89,7 @@ private static List ParseRelations(string rootDir, IReadOnlyDi try { var text = File.ReadAllText(relationsFileName); - var relationStrings = JsonConvert.DeserializeObject>(text) ?? new List(); + var relationStrings = JsonConvert.DeserializeObject>(text) ?? []; relationStrings.Sort(); var parsedRelations = relationStrings.Select(relationString => ParseRelation(relationString, quantities)).ToList(); @@ -119,7 +109,7 @@ private static QuantityRelation ParseRelation(string relationString, IReadOnlyDi { var segments = relationString.Split(' '); - if (segments.Length != 5 || segments[1] != "=") + if (segments is not [_, "=", _, "*" or "/", _]) { throw new Exception($"Invalid relation string: {relationString}"); } diff --git a/CodeGen/JsonTypes/QuantityRelation.cs b/CodeGen/JsonTypes/QuantityRelation.cs index 66c6108124..fa7c73056c 100644 --- a/CodeGen/JsonTypes/QuantityRelation.cs +++ b/CodeGen/JsonTypes/QuantityRelation.cs @@ -15,13 +15,5 @@ internal record QuantityRelation public Quantity ResultQuantity = null!; public Unit ResultUnit = null!; - - public QuantityRelation Swapped() => this with - { - LeftQuantity = RightQuantity, - LeftUnit = RightUnit, - RightQuantity = LeftQuantity, - RightUnit = LeftUnit, - }; } } \ No newline at end of file diff --git a/CodeGen/JsonTypes/Unit.cs b/CodeGen/JsonTypes/Unit.cs index eb6a382a3b..4a775c08f9 100644 --- a/CodeGen/JsonTypes/Unit.cs +++ b/CodeGen/JsonTypes/Unit.cs @@ -5,7 +5,7 @@ namespace CodeGen.JsonTypes { - internal record Unit + internal class Unit { // 0649 Field is never assigned to #pragma warning disable 0649 From 4de9789b42cea22e23fc2a48c5761c091443dec0 Mon Sep 17 00:00:00 2001 From: Muximize Date: Mon, 8 Jan 2024 12:30:28 +0100 Subject: [PATCH 05/12] Sort inferred relations to keep generated operators in a consistent order --- CodeGen/Generators/QuantityRelationsParser.cs | 3 +++ CodeGen/JsonTypes/QuantityRelation.cs | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CodeGen/Generators/QuantityRelationsParser.cs b/CodeGen/Generators/QuantityRelationsParser.cs index 00664b036d..9352cd6334 100644 --- a/CodeGen/Generators/QuantityRelationsParser.cs +++ b/CodeGen/Generators/QuantityRelationsParser.cs @@ -60,6 +60,9 @@ public static void ParseAndApplyRelations(string rootDir, Quantity[] quantities) .Select(r => r with { RightQuantity = timeSpanQuantity }) .ToList()); + // Sort all relations to keep generated operators in a consistent order. + relations.Sort(); + foreach (var quantity in quantities) { var quantityRelations = new List(); diff --git a/CodeGen/JsonTypes/QuantityRelation.cs b/CodeGen/JsonTypes/QuantityRelation.cs index fa7c73056c..fa9c4199b3 100644 --- a/CodeGen/JsonTypes/QuantityRelation.cs +++ b/CodeGen/JsonTypes/QuantityRelation.cs @@ -1,9 +1,11 @@ // 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; + namespace CodeGen.JsonTypes { - internal record QuantityRelation + internal record QuantityRelation : IComparable { public string Operator = null!; @@ -15,5 +17,18 @@ internal record QuantityRelation public Quantity ResultQuantity = null!; public Unit ResultUnit = null!; + + private string SortString => ResultQuantity.Name + + ResultUnit.SingularName + + LeftQuantity.Name + + LeftUnit.SingularName + + Operator + + RightQuantity.Name + + RightUnit.SingularName; + + public int CompareTo(QuantityRelation? other) + { + return string.Compare(SortString, other?.SortString, StringComparison.Ordinal); + } } } \ No newline at end of file From 7046318fd078e4b15669333fe9567dfe9804e930 Mon Sep 17 00:00:00 2001 From: Muximize Date: Mon, 8 Jan 2024 12:31:06 +0100 Subject: [PATCH 06/12] Generated code with re-sorted operators --- .../Quantities/Acceleration.g.cs | 14 ++--- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 14 ++--- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 14 ++--- .../BrakeSpecificFuelConsumption.g.cs | 14 ++--- .../GeneratedCode/Quantities/Density.g.cs | 14 ++--- .../Quantities/ElectricCharge.g.cs | 14 ++--- .../Quantities/ElectricCurrent.g.cs | 40 +++++++------- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 14 ++--- .../Quantities/KinematicViscosity.g.cs | 26 +++++----- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 14 ++--- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 52 +++++++++---------- .../GeneratedCode/Quantities/MassFlow.g.cs | 42 +++++++-------- .../GeneratedCode/Quantities/MolarFlow.g.cs | 26 +++++----- .../GeneratedCode/Quantities/MolarMass.g.cs | 14 ++--- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 26 +++++----- .../GeneratedCode/Quantities/Pressure.g.cs | 14 ++--- .../Quantities/SpecificEnergy.g.cs | 14 ++--- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 40 +++++++------- .../Quantities/TemperatureDelta.g.cs | 14 ++--- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 12 ++--- 20 files changed, 216 insertions(+), 216 deletions(-) diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 725c643340..ce03b1f8be 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -44,9 +44,9 @@ namespace UnitsNet #if NET7_0_OR_GREATER IMultiplyOperators, IDivisionOperators, + IDivisionOperators, IMultiplyOperators, IMultiplyOperators, - IDivisionOperators, IMultiplyOperators, #endif IComparable, @@ -689,6 +689,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel return Jerk.FromMetersPerSecondCubed(acceleration.MetersPerSecondSquared / duration.Seconds); } + /// Get from / . + public static Jerk operator /(Acceleration acceleration, TimeSpan timeSpan) + { + return Jerk.FromMetersPerSecondCubed(acceleration.MetersPerSecondSquared / timeSpan.TotalSeconds); + } + /// Get from * . public static SpecificWeight operator *(Acceleration acceleration, Density density) { @@ -701,12 +707,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel return Speed.FromMetersPerSecond(acceleration.MetersPerSecondSquared * duration.Seconds); } - /// Get from / . - public static Jerk operator /(Acceleration acceleration, TimeSpan timeSpan) - { - return Jerk.FromMetersPerSecondCubed(acceleration.MetersPerSecondSquared / timeSpan.TotalSeconds); - } - /// Get from * . public static Speed operator *(Acceleration acceleration, TimeSpan timeSpan) { diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 4761c4392e..a4fb3cc421 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -43,8 +43,8 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IDivisionOperators, - IMultiplyOperators, IDivisionOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -716,18 +716,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle return RotationalSpeed.FromRadiansPerSecond(angle.Radians / duration.Seconds); } - /// Get from * . - public static Torque operator *(Angle angle, RotationalStiffness rotationalStiffness) - { - return Torque.FromNewtonMeters(angle.Radians * rotationalStiffness.NewtonMetersPerRadian); - } - /// Get from / . public static RotationalSpeed operator /(Angle angle, TimeSpan timeSpan) { return RotationalSpeed.FromRadiansPerSecond(angle.Radians / timeSpan.TotalSeconds); } + /// Get from * . + public static Torque operator *(Angle angle, RotationalStiffness rotationalStiffness) + { + return Torque.FromNewtonMeters(angle.Radians * rotationalStiffness.NewtonMetersPerRadian); + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 195f583d77..fda5efd22d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -47,8 +47,8 @@ namespace UnitsNet IDivisionOperators, IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, @@ -713,18 +713,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU return LuminousIntensity.FromCandela(area.SquareMeters * luminance.CandelasPerSquareMeter); } - /// Get from * . - public static Mass operator *(Area area, AreaDensity areaDensity) - { - return Mass.FromKilograms(area.SquareMeters * areaDensity.KilogramsPerSquareMeter); - } - /// Get from * . public static MassFlow operator *(Area area, MassFlux massFlux) { return MassFlow.FromGramsPerSecond(area.SquareMeters * massFlux.GramsPerSecondPerSquareMeter); } + /// Get from * . + public static Mass operator *(Area area, AreaDensity areaDensity) + { + return Mass.FromKilograms(area.SquareMeters * areaDensity.KilogramsPerSquareMeter); + } + /// Get from * . public static Power operator *(Area area, HeatFlux heatFlux) { diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index e90e9e2e5f..8641493c0f 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -42,8 +42,8 @@ namespace UnitsNet public readonly partial struct BrakeSpecificFuelConsumption : IArithmeticQuantity, #if NET7_0_OR_GREATER - IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -475,12 +475,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake #region Relational Operators - /// Get from * . - public static double operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, SpecificEnergy specificEnergy) - { - return brakeSpecificFuelConsumption.KilogramsPerJoule * specificEnergy.JoulesPerKilogram; - } - /// Get from * . public static MassFlow operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, Power power) { @@ -493,6 +487,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake return SpecificEnergy.FromJoulesPerKilogram(value / brakeSpecificFuelConsumption.KilogramsPerJoule); } + /// Get from * . + public static double operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, SpecificEnergy specificEnergy) + { + return brakeSpecificFuelConsumption.KilogramsPerJoule * specificEnergy.JoulesPerKilogram; + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 423151009a..402868e34a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -47,10 +47,10 @@ namespace UnitsNet #if NET7_0_OR_GREATER IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, #endif IComparable, @@ -1449,12 +1449,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return LinearDensity.FromKilogramsPerMeter(density.KilogramsPerCubicMeter * area.SquareMeters); } - /// Get from * . - public static Mass operator *(Density density, Volume volume) - { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); - } - /// Get from * . public static MassConcentration operator *(Density density, VolumeConcentration volumeConcentration) { @@ -1473,6 +1467,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); } + /// Get from * . + public static Mass operator *(Density density, Volume volume) + { + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + } + /// Get from * . public static SpecificWeight operator *(Density density, Acceleration acceleration) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index ba31a49c68..b5a88574de 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -47,8 +47,8 @@ namespace UnitsNet #if NET7_0_OR_GREATER IDivisionOperators, IDivisionOperators, - IMultiplyOperators, IDivisionOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -636,18 +636,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return ElectricCurrent.FromAmperes(electricCharge.AmpereHours / duration.Hours); } - /// Get from * . - public static Energy operator *(ElectricCharge electricCharge, ElectricPotential electricPotential) - { - return Energy.FromJoules(electricCharge.Coulombs * electricPotential.Volts); - } - /// Get from / . public static ElectricCurrent operator /(ElectricCharge electricCharge, TimeSpan timeSpan) { return ElectricCurrent.FromAmperes(electricCharge.AmpereHours / timeSpan.TotalHours); } + /// Get from * . + public static Energy operator *(ElectricCharge electricCharge, ElectricPotential electricPotential) + { + return Energy.FromJoules(electricCharge.Coulombs * electricPotential.Volts); + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 57c083f1c8..bf5fb2e7dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -43,11 +43,11 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, + IMultiplyOperators, IDivisionOperators, + IDivisionOperators, IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, - IDivisionOperators, #endif IComparable, IComparable, @@ -593,24 +593,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return ElectricCharge.FromAmpereHours(electricCurrent.Amperes * duration.Hours); } - /// Get from / . - public static ElectricCurrentGradient operator /(ElectricCurrent electricCurrent, Duration duration) - { - return ElectricCurrentGradient.FromAmperesPerSecond(electricCurrent.Amperes / duration.Seconds); - } - - /// Get from * . - public static ElectricPotential operator *(ElectricCurrent electricCurrent, ElectricResistance electricResistance) - { - return ElectricPotential.FromVolts(electricCurrent.Amperes * electricResistance.Ohms); - } - - /// Get from * . - public static Power operator *(ElectricCurrent electricCurrent, ElectricPotential electricPotential) - { - return Power.FromWatts(electricCurrent.Amperes * electricPotential.Volts); - } - /// Get from * . public static ElectricCharge operator *(ElectricCurrent electricCurrent, TimeSpan timeSpan) { @@ -623,12 +605,30 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return ElectricCharge.FromAmpereHours(timeSpan.TotalHours * electricCurrent.Amperes); } + /// Get from / . + public static ElectricCurrentGradient operator /(ElectricCurrent electricCurrent, Duration duration) + { + return ElectricCurrentGradient.FromAmperesPerSecond(electricCurrent.Amperes / duration.Seconds); + } + /// Get from / . public static ElectricCurrentGradient operator /(ElectricCurrent electricCurrent, TimeSpan timeSpan) { return ElectricCurrentGradient.FromAmperesPerSecond(electricCurrent.Amperes / timeSpan.TotalSeconds); } + /// Get from * . + public static ElectricPotential operator *(ElectricCurrent electricCurrent, ElectricResistance electricResistance) + { + return ElectricPotential.FromVolts(electricCurrent.Amperes * electricResistance.Ohms); + } + + /// Get from * . + public static Power operator *(ElectricCurrent electricCurrent, ElectricPotential electricPotential) + { + return Power.FromWatts(electricCurrent.Amperes * electricPotential.Volts); + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 673d0ca5f2..e36ff1fdf0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -49,9 +49,9 @@ namespace UnitsNet IDivisionOperators, IMultiplyOperators, IDivisionOperators, + IDivisionOperators, IDivisionOperators, IDivisionOperators, - IDivisionOperators, #endif IComparable, IComparable, @@ -1191,6 +1191,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return Power.FromWatts(energy.Joules / duration.Seconds); } + /// Get from / . + public static Power operator /(Energy energy, TimeSpan timeSpan) + { + return Power.FromWatts(energy.Joules / timeSpan.TotalSeconds); + } + /// Get from / . public static SpecificEnergy operator /(Energy energy, Mass mass) { @@ -1203,12 +1209,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return TemperatureDelta.FromKelvins(energy.Joules / entropy.JoulesPerKelvin); } - /// Get from / . - public static Power operator /(Energy energy, TimeSpan timeSpan) - { - return Power.FromWatts(energy.Joules / timeSpan.TotalSeconds); - } - #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 71eed52ba8..deedb07266 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -46,9 +46,9 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, IDivisionOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -594,18 +594,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); } - /// Get from * . - public static DynamicViscosity operator *(KinematicViscosity kinematicViscosity, Density density) - { - return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); - } - - /// Get from / . - public static Speed operator /(KinematicViscosity kinematicViscosity, Length length) - { - return Speed.FromMetersPerSecond(kinematicViscosity.SquareMetersPerSecond / length.Meters); - } - /// Get from * . public static Area operator *(KinematicViscosity kinematicViscosity, TimeSpan timeSpan) { @@ -618,6 +606,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem return Area.FromSquareMeters(timeSpan.TotalSeconds * kinematicViscosity.SquareMetersPerSecond); } + /// Get from * . + public static DynamicViscosity operator *(KinematicViscosity kinematicViscosity, Density density) + { + return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); + } + + /// Get from / . + public static Speed operator /(KinematicViscosity kinematicViscosity, Length length) + { + return Speed.FromMetersPerSecond(kinematicViscosity.SquareMetersPerSecond / length.Meters); + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index e0e2fc0314..ec8a4ad7ff 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -50,10 +50,10 @@ namespace UnitsNet IMultiplyOperators, IMultiplyOperators, IDivisionOperators, + IDivisionOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, - IDivisionOperators, #endif IComparable, IComparable, @@ -1242,6 +1242,12 @@ public ReciprocalLength Inverse() return Speed.FromMetersPerSecond(length.Meters / duration.Seconds); } + /// Get from / . + public static Speed operator /(Length length, TimeSpan timeSpan) + { + return Speed.FromMetersPerSecond(length.Meters / timeSpan.TotalSeconds); + } + /// Get from * . public static TemperatureDelta operator *(Length length, TemperatureGradient temperatureGradient) { @@ -1260,12 +1266,6 @@ public ReciprocalLength Inverse() return Volume.FromCubicMeters(length.Meters * area.SquareMeters); } - /// Get from / . - public static Speed operator /(Length length, TimeSpan timeSpan) - { - return Speed.FromMetersPerSecond(length.Meters / timeSpan.TotalSeconds); - } - #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 2d7fb4290b..548941e138 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -43,20 +43,20 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IDivisionOperators, - IDivisionOperators, IDivisionOperators, + IDivisionOperators, IDivisionOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IDivisionOperators, IDivisionOperators, - IDivisionOperators, - IMultiplyOperators, IDivisionOperators, - IDivisionOperators, - IMultiplyOperators, IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, + IMultiplyOperators, + IDivisionOperators, #endif IComparable, IComparable, @@ -926,18 +926,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return AmountOfSubstance.FromMoles(mass.Kilograms / molarMass.KilogramsPerMole); } - /// Get from / . - public static Area operator /(Mass mass, AreaDensity areaDensity) - { - return Area.FromSquareMeters(mass.Kilograms / areaDensity.KilogramsPerSquareMeter); - } - /// Get from / . public static AreaDensity operator /(Mass mass, Area area) { return AreaDensity.FromKilogramsPerSquareMeter(mass.Kilograms / area.SquareMeters); } + /// Get from / . + public static Area operator /(Mass mass, AreaDensity areaDensity) + { + return Area.FromSquareMeters(mass.Kilograms / areaDensity.KilogramsPerSquareMeter); + } + /// Get from / . public static Density operator /(Mass mass, Volume volume) { @@ -974,28 +974,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return LinearDensity.FromKilogramsPerMeter(mass.Kilograms / length.Meters); } - /// Get from / . - public static Mass operator /(Mass mass, MassFraction massFraction) + /// Get from / . + public static MassFlow operator /(Mass mass, Duration duration) { - return Mass.FromKilograms(mass.Kilograms / massFraction.DecimalFractions); + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / duration.Seconds); } - /// Get from * . - public static Mass operator *(Mass mass, MassFraction massFraction) + /// Get from / . + public static MassFlow operator /(Mass mass, TimeSpan timeSpan) { - return Mass.FromKilograms(mass.Kilograms * massFraction.DecimalFractions); + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / timeSpan.TotalSeconds); } - /// Get from / . - public static MassFlow operator /(Mass mass, Duration duration) + /// Get from * . + public static Mass operator *(Mass mass, MassFraction massFraction) { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms / duration.Seconds); + return Mass.FromKilograms(mass.Kilograms * massFraction.DecimalFractions); } - /// Get from / . - public static Volume operator /(Mass mass, Density density) + /// Get from / . + public static Mass operator /(Mass mass, MassFraction massFraction) { - return Volume.FromCubicMeters(mass.Kilograms / density.KilogramsPerCubicMeter); + return Mass.FromKilograms(mass.Kilograms / massFraction.DecimalFractions); } /// Get from * . @@ -1004,10 +1004,10 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return Volume.FromCubicMeters(mass.Kilograms * specificVolume.CubicMetersPerKilogram); } - /// Get from / . - public static MassFlow operator /(Mass mass, TimeSpan timeSpan) + /// Get from / . + public static Volume operator /(Mass mass, Density density) { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms / timeSpan.TotalSeconds); + return Volume.FromCubicMeters(mass.Kilograms / density.KilogramsPerCubicMeter); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 1d9487240c..c154a74bbe 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -45,12 +45,12 @@ namespace UnitsNet IDivisionOperators, IDivisionOperators, IDivisionOperators, - IMultiplyOperators, IDivisionOperators, - IDivisionOperators, + IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, + IDivisionOperators, IDivisionOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -1040,22 +1040,28 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return Density.FromKilogramsPerCubicMeter(massFlow.KilogramsPerSecond / volumeFlow.CubicMetersPerSecond); } + /// Get from / . + public static MassFlux operator /(MassFlow massFlow, Area area) + { + return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); + } + /// Get from * . public static Mass operator *(MassFlow massFlow, Duration duration) { return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); } - /// Get from / . - public static MassFlux operator /(MassFlow massFlow, Area area) + /// Get from * . + public static Mass operator *(MassFlow massFlow, TimeSpan timeSpan) { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); + return Mass.FromKilograms(massFlow.KilogramsPerSecond * timeSpan.TotalSeconds); } - /// Get from / . - public static Power operator /(MassFlow massFlow, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + /// Get from * . + public static Mass operator *(TimeSpan timeSpan, MassFlow massFlow) { - return Power.FromWatts(massFlow.KilogramsPerSecond / brakeSpecificFuelConsumption.KilogramsPerJoule); + return Mass.FromKilograms(timeSpan.TotalSeconds * massFlow.KilogramsPerSecond); } /// Get from * . @@ -1064,22 +1070,16 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); } - /// Get from / . - public static VolumeFlow operator /(MassFlow massFlow, Density density) - { - return VolumeFlow.FromCubicMetersPerSecond(massFlow.KilogramsPerSecond / density.KilogramsPerCubicMeter); - } - - /// Get from * . - public static Mass operator *(MassFlow massFlow, TimeSpan timeSpan) + /// Get from / . + public static Power operator /(MassFlow massFlow, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * timeSpan.TotalSeconds); + return Power.FromWatts(massFlow.KilogramsPerSecond / brakeSpecificFuelConsumption.KilogramsPerJoule); } - /// Get from * . - public static Mass operator *(TimeSpan timeSpan, MassFlow massFlow) + /// Get from / . + public static VolumeFlow operator /(MassFlow massFlow, Density density) { - return Mass.FromKilograms(timeSpan.TotalSeconds * massFlow.KilogramsPerSecond); + return VolumeFlow.FromCubicMetersPerSecond(massFlow.KilogramsPerSecond / density.KilogramsPerCubicMeter); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index 6a66d0c379..00f765bec9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -43,9 +43,9 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, IDivisionOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -591,18 +591,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return AmountOfSubstance.FromKilomoles(molarFlow.KilomolesPerSecond * duration.Seconds); } - /// Get from * . - public static MassFlow operator *(MolarFlow molarFlow, MolarMass molarMass) - { - return MassFlow.FromKilogramsPerSecond(molarFlow.KilomolesPerSecond * molarMass.KilogramsPerKilomole); - } - - /// Get from / . - public static VolumeFlow operator /(MolarFlow molarFlow, Molarity molarity) - { - return VolumeFlow.FromCubicMetersPerSecond(molarFlow.MolesPerSecond / molarity.MolesPerCubicMeter); - } - /// Get from * . public static AmountOfSubstance operator *(MolarFlow molarFlow, TimeSpan timeSpan) { @@ -615,6 +603,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return AmountOfSubstance.FromKilomoles(timeSpan.TotalSeconds * molarFlow.KilomolesPerSecond); } + /// Get from * . + public static MassFlow operator *(MolarFlow molarFlow, MolarMass molarMass) + { + return MassFlow.FromKilogramsPerSecond(molarFlow.KilomolesPerSecond * molarMass.KilogramsPerKilomole); + } + + /// Get from / . + public static VolumeFlow operator /(MolarFlow molarFlow, Molarity molarity) + { + return VolumeFlow.FromCubicMetersPerSecond(molarFlow.MolesPerSecond / molarity.MolesPerCubicMeter); + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 3e29004ac2..b35bad827c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -42,9 +42,9 @@ namespace UnitsNet public readonly partial struct MolarMass : IArithmeticQuantity, #if NET7_0_OR_GREATER - IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -656,12 +656,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Relational Operators - /// Get from * . - public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) - { - return Mass.FromGrams(molarMass.GramsPerMole * amountOfSubstance.Moles); - } - /// Get from * . public static MassConcentration operator *(MolarMass molarMass, Molarity molarity) { @@ -674,6 +668,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return MassFlow.FromKilogramsPerSecond(molarMass.KilogramsPerKilomole * molarFlow.KilomolesPerSecond); } + /// Get from * . + public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) + { + return Mass.FromGrams(molarMass.GramsPerMole * amountOfSubstance.Moles); + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index f074e2a525..475bbbe81e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -46,6 +46,7 @@ namespace UnitsNet IDivisionOperators, IDivisionOperators, IMultiplyOperators, + IMultiplyOperators, IDivisionOperators, IDivisionOperators, IMultiplyOperators, @@ -53,7 +54,6 @@ namespace UnitsNet IDivisionOperators, IDivisionOperators, IDivisionOperators, - IMultiplyOperators, #endif IDecimalQuantity, IComparable, @@ -924,6 +924,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return Energy.FromJoules((double)power.Watts * duration.Seconds); } + /// Get from * . + public static Energy operator *(Power power, TimeSpan timeSpan) + { + return Energy.FromJoules((double)power.Watts * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Energy operator *(TimeSpan timeSpan, Power power) + { + return Energy.FromJoules(timeSpan.TotalSeconds * (double)power.Watts); + } + /// Get from / . public static Force operator /(Power power, Speed speed) { @@ -966,18 +978,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return Torque.FromNewtonMeters((double)power.Watts / rotationalSpeed.RadiansPerSecond); } - /// Get from * . - public static Energy operator *(Power power, TimeSpan timeSpan) - { - return Energy.FromJoules((double)power.Watts * timeSpan.TotalSeconds); - } - - /// Get from * . - public static Energy operator *(TimeSpan timeSpan, Power power) - { - return Energy.FromJoules(timeSpan.TotalSeconds * (double)power.Watts); - } - #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 777d8c544d..db3e6c06e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -47,8 +47,8 @@ namespace UnitsNet IDivisionOperators, IDivisionOperators, IDivisionOperators, - IDivisionOperators, IDivisionOperators, + IDivisionOperators, #endif IComparable, IComparable, @@ -1338,18 +1338,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return PressureChangeRate.FromPascalsPerSecond(pressure.Pascals / duration.Seconds); } - /// Get from / . - public static SpecificWeight operator /(Pressure pressure, Length length) - { - return SpecificWeight.FromNewtonsPerCubicMeter(pressure.Pascals / length.Meters); - } - /// Get from / . public static PressureChangeRate operator /(Pressure pressure, TimeSpan timeSpan) { return PressureChangeRate.FromPascalsPerSecond(pressure.Pascals / timeSpan.TotalSeconds); } + /// Get from / . + public static SpecificWeight operator /(Pressure pressure, Length length) + { + return SpecificWeight.FromNewtonsPerCubicMeter(pressure.Pascals / length.Meters); + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 2c71ec1cbd..74313501ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -45,10 +45,10 @@ namespace UnitsNet public readonly partial struct SpecificEnergy : IArithmeticQuantity, #if NET7_0_OR_GREATER - IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IDivisionOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -972,12 +972,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value / specificEnergy.JoulesPerKilogram); } - /// Get from * . - public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) - { - return specificEnergy.JoulesPerKilogram * brakeSpecificFuelConsumption.KilogramsPerJoule; - } - /// Get from * . public static Energy operator *(SpecificEnergy specificEnergy, Mass mass) { @@ -996,6 +990,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return SpecificEntropy.FromJoulesPerKilogramKelvin(specificEnergy.JoulesPerKilogram / temperatureDelta.Kelvins); } + /// Get from * . + public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + { + return specificEnergy.JoulesPerKilogram * brakeSpecificFuelConsumption.KilogramsPerJoule; + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 4f20de6ffc..2f291ae723 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -43,15 +43,15 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IDivisionOperators, + IDivisionOperators, IDivisionOperators, IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, - IDivisionOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -1029,6 +1029,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / duration.Seconds); } + /// Get from / . + public static Acceleration operator /(Speed speed, TimeSpan timeSpan) + { + return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / timeSpan.TotalSeconds); + } + /// Get from / . public static Duration operator /(Speed speed, Acceleration acceleration) { @@ -1047,6 +1053,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); } + /// Get from * . + public static Length operator *(Speed speed, TimeSpan timeSpan) + { + return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); + } + + /// Get from * . + public static Length operator *(TimeSpan timeSpan, Speed speed) + { + return Length.FromMeters(timeSpan.TotalSeconds * speed.MetersPerSecond); + } + /// Get from * . public static MassFlux operator *(Speed speed, Density density) { @@ -1071,24 +1089,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return VolumeFlow.FromCubicMetersPerSecond(speed.MetersPerSecond * area.SquareMeters); } - /// Get from / . - public static Acceleration operator /(Speed speed, TimeSpan timeSpan) - { - return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / timeSpan.TotalSeconds); - } - - /// Get from * . - public static Length operator *(Speed speed, TimeSpan timeSpan) - { - return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); - } - - /// Get from * . - public static Length operator *(TimeSpan timeSpan, Speed speed) - { - return Length.FromMeters(timeSpan.TotalSeconds * speed.MetersPerSecond); - } - #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 3519803abd..32c9ae4a4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -42,11 +42,11 @@ namespace UnitsNet public readonly partial struct TemperatureDelta : IArithmeticQuantity, #if NET7_0_OR_GREATER - IMultiplyOperators, IMultiplyOperators, IDivisionOperators, IMultiplyOperators, IDivisionOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -586,12 +586,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #region Relational Operators - /// Get from * . - public static double operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion coefficientOfThermalExpansion) - { - return temperatureDelta.Kelvins * coefficientOfThermalExpansion.PerKelvin; - } - /// Get from * . public static Energy operator *(TemperatureDelta temperatureDelta, Entropy entropy) { @@ -616,6 +610,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return TemperatureGradient.FromKelvinsPerMeter(temperatureDelta.Kelvins / length.Meters); } + /// Get from * . + public static double operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion coefficientOfThermalExpansion) + { + return temperatureDelta.Kelvins * coefficientOfThermalExpansion.PerKelvin; + } + #endregion #region Equality / IComparable diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index f3eadae85c..9cf7d31375 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -1648,6 +1648,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return Speed.FromMetersPerSecond(volumeFlow.CubicMetersPerSecond / area.SquareMeters); } + /// Get from * . + public static Volume operator *(TimeSpan timeSpan, VolumeFlow volumeFlow) + { + return Volume.FromCubicMeters(timeSpan.TotalSeconds * volumeFlow.CubicMetersPerSecond); + } + /// Get from * . public static Volume operator *(VolumeFlow volumeFlow, Duration duration) { @@ -1660,12 +1666,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * timeSpan.TotalSeconds); } - /// Get from * . - public static Volume operator *(TimeSpan timeSpan, VolumeFlow volumeFlow) - { - return Volume.FromCubicMeters(timeSpan.TotalSeconds * volumeFlow.CubicMetersPerSecond); - } - #endregion #region Equality / IComparable From 59e8f7fd8834ac8f68a53571251b30db921f7ad1 Mon Sep 17 00:00:00 2001 From: Muximize Date: Tue, 9 Jan 2024 01:25:29 +0100 Subject: [PATCH 07/12] Add examples --- CodeGen/Generators/QuantityRelationsParser.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CodeGen/Generators/QuantityRelationsParser.cs b/CodeGen/Generators/QuantityRelationsParser.cs index 9352cd6334..617525ec9e 100644 --- a/CodeGen/Generators/QuantityRelationsParser.cs +++ b/CodeGen/Generators/QuantityRelationsParser.cs @@ -18,12 +18,21 @@ internal static class QuantityRelationsParser { /// /// Parse and apply relations to quantities. + /// + /// The relations are defined in UnitRelations.json /// Each defined relation can be applied multiple times to one or two quantities depending on the operator and the operands. /// - /// The format of a relation definition is "Quantity.Unit operator Quantity.Unit = Quantity.Unit". + /// The format of a relation definition is "Quantity.Unit operator Quantity.Unit = Quantity.Unit" (See examples below). /// "double" can be used as a unitless operand. /// "1" can be used as the left operand to define inverse relations. /// + /// + /// [ + /// "Power.Watt = ElectricPotential.Volt * ElectricCurrent.Ampere", + /// "Speed.MeterPerSecond = Length.Meter / Duration.Second", + /// "ReciprocalLength.InverseMeter = 1 / Length.Meter" + /// ] + /// /// Repository root directory. /// List of previously parsed Quantity objects. public static void ParseAndApplyRelations(string rootDir, Quantity[] quantities) From 049eaf9577de333bcb912fbd255bb5ad5b7391fe Mon Sep 17 00:00:00 2001 From: Muximize Date: Tue, 9 Jan 2024 01:27:07 +0100 Subject: [PATCH 08/12] Automatically remove duplicate relation definitions --- CodeGen/Generators/QuantityRelationsParser.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CodeGen/Generators/QuantityRelationsParser.cs b/CodeGen/Generators/QuantityRelationsParser.cs index 617525ec9e..3d8e447b36 100644 --- a/CodeGen/Generators/QuantityRelationsParser.cs +++ b/CodeGen/Generators/QuantityRelationsParser.cs @@ -101,8 +101,7 @@ private static List ParseRelations(string rootDir, IReadOnlyDi try { var text = File.ReadAllText(relationsFileName); - var relationStrings = JsonConvert.DeserializeObject>(text) ?? []; - relationStrings.Sort(); + var relationStrings = JsonConvert.DeserializeObject>(text) ?? []; var parsedRelations = relationStrings.Select(relationString => ParseRelation(relationString, quantities)).ToList(); From 7a52a91d92108bf22c172c6d5ed064c69e3d36ea Mon Sep 17 00:00:00 2001 From: Muximize Date: Tue, 9 Jan 2024 01:28:12 +0100 Subject: [PATCH 09/12] Throw exception on duplicate inferred relations --- CodeGen/Generators/QuantityRelationsParser.cs | 15 ++++++++++++++- CodeGen/JsonTypes/QuantityRelation.cs | 14 +++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CodeGen/Generators/QuantityRelationsParser.cs b/CodeGen/Generators/QuantityRelationsParser.cs index 3d8e447b36..38f7abe5e8 100644 --- a/CodeGen/Generators/QuantityRelationsParser.cs +++ b/CodeGen/Generators/QuantityRelationsParser.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using CodeGen.Exceptions; using CodeGen.JsonTypes; using Newtonsoft.Json; @@ -71,6 +72,18 @@ public static void ParseAndApplyRelations(string rootDir, Quantity[] quantities) // Sort all relations to keep generated operators in a consistent order. relations.Sort(); + + var duplicates = relations + .GroupBy(r => r.SortString) + .Where(g => g.Count() > 1) + .Select(g => g.Key) + .ToList(); + + if (duplicates.Any()) + { + var list = string.Join("\n ", duplicates); + throw new UnitsNetCodeGenException($"Duplicate inferred relations:\n {list}"); + } foreach (var quantity in quantities) { @@ -112,7 +125,7 @@ private static List ParseRelations(string rootDir, IReadOnlyDi } catch (Exception e) { - throw new Exception($"Error parsing relations file: {relationsFileName}", e); + throw new UnitsNetCodeGenException($"Error parsing relations file: {relationsFileName}", e); } } diff --git a/CodeGen/JsonTypes/QuantityRelation.cs b/CodeGen/JsonTypes/QuantityRelation.cs index fa9c4199b3..9aec29c2a9 100644 --- a/CodeGen/JsonTypes/QuantityRelation.cs +++ b/CodeGen/JsonTypes/QuantityRelation.cs @@ -18,17 +18,17 @@ internal record QuantityRelation : IComparable public Quantity ResultQuantity = null!; public Unit ResultUnit = null!; - private string SortString => ResultQuantity.Name - + ResultUnit.SingularName - + LeftQuantity.Name - + LeftUnit.SingularName - + Operator - + RightQuantity.Name - + RightUnit.SingularName; + public string SortString => ResultQuantity.Name + PrependDot(ResultUnit.SingularName) + + " = " + + LeftQuantity.Name + PrependDot(LeftUnit.SingularName) + + " " + Operator + " " + + RightQuantity.Name + PrependDot(RightUnit.SingularName); public int CompareTo(QuantityRelation? other) { return string.Compare(SortString, other?.SortString, StringComparison.Ordinal); } + + private static string PrependDot(string? s) => s == null ? string.Empty : "." + s; } } \ No newline at end of file From 5c9abede27c1f86066cad16da370808b94acc843 Mon Sep 17 00:00:00 2001 From: Muximize Date: Tue, 9 Jan 2024 01:29:45 +0100 Subject: [PATCH 10/12] Generate code: changed SortString format changes the order of some relations --- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 14 +++---- .../GeneratedCode/Quantities/Density.g.cs | 14 +++---- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 42 +++++++++---------- .../GeneratedCode/Quantities/MassFlow.g.cs | 14 +++---- .../GeneratedCode/Quantities/MolarMass.g.cs | 14 +++---- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index fda5efd22d..195f583d77 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -47,8 +47,8 @@ namespace UnitsNet IDivisionOperators, IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, @@ -713,18 +713,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU return LuminousIntensity.FromCandela(area.SquareMeters * luminance.CandelasPerSquareMeter); } - /// Get from * . - public static MassFlow operator *(Area area, MassFlux massFlux) - { - return MassFlow.FromGramsPerSecond(area.SquareMeters * massFlux.GramsPerSecondPerSquareMeter); - } - /// Get from * . public static Mass operator *(Area area, AreaDensity areaDensity) { return Mass.FromKilograms(area.SquareMeters * areaDensity.KilogramsPerSquareMeter); } + /// Get from * . + public static MassFlow operator *(Area area, MassFlux massFlux) + { + return MassFlow.FromGramsPerSecond(area.SquareMeters * massFlux.GramsPerSecondPerSquareMeter); + } + /// Get from * . public static Power operator *(Area area, HeatFlux heatFlux) { diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 402868e34a..423151009a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -47,10 +47,10 @@ namespace UnitsNet #if NET7_0_OR_GREATER IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, IMultiplyOperators, #endif IComparable, @@ -1449,6 +1449,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return LinearDensity.FromKilogramsPerMeter(density.KilogramsPerCubicMeter * area.SquareMeters); } + /// Get from * . + public static Mass operator *(Density density, Volume volume) + { + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + } + /// Get from * . public static MassConcentration operator *(Density density, VolumeConcentration volumeConcentration) { @@ -1467,12 +1473,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); } - /// Get from * . - public static Mass operator *(Density density, Volume volume) - { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); - } - /// Get from * . public static SpecificWeight operator *(Density density, Acceleration acceleration) { diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 548941e138..750b8a6985 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -43,18 +43,18 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IDivisionOperators, - IDivisionOperators, IDivisionOperators, + IDivisionOperators, IDivisionOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IDivisionOperators, IDivisionOperators, - IDivisionOperators, - IDivisionOperators, IMultiplyOperators, IDivisionOperators, + IDivisionOperators, + IDivisionOperators, IMultiplyOperators, IDivisionOperators, #endif @@ -926,18 +926,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return AmountOfSubstance.FromMoles(mass.Kilograms / molarMass.KilogramsPerMole); } - /// Get from / . - public static AreaDensity operator /(Mass mass, Area area) - { - return AreaDensity.FromKilogramsPerSquareMeter(mass.Kilograms / area.SquareMeters); - } - /// Get from / . public static Area operator /(Mass mass, AreaDensity areaDensity) { return Area.FromSquareMeters(mass.Kilograms / areaDensity.KilogramsPerSquareMeter); } + /// Get from / . + public static AreaDensity operator /(Mass mass, Area area) + { + return AreaDensity.FromKilogramsPerSquareMeter(mass.Kilograms / area.SquareMeters); + } + /// Get from / . public static Density operator /(Mass mass, Volume volume) { @@ -974,18 +974,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return LinearDensity.FromKilogramsPerMeter(mass.Kilograms / length.Meters); } - /// Get from / . - public static MassFlow operator /(Mass mass, Duration duration) - { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms / duration.Seconds); - } - - /// Get from / . - public static MassFlow operator /(Mass mass, TimeSpan timeSpan) - { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms / timeSpan.TotalSeconds); - } - /// Get from * . public static Mass operator *(Mass mass, MassFraction massFraction) { @@ -998,6 +986,18 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return Mass.FromKilograms(mass.Kilograms / massFraction.DecimalFractions); } + /// Get from / . + public static MassFlow operator /(Mass mass, Duration duration) + { + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / duration.Seconds); + } + + /// Get from / . + public static MassFlow operator /(Mass mass, TimeSpan timeSpan) + { + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / timeSpan.TotalSeconds); + } + /// Get from * . public static Volume operator *(Mass mass, SpecificVolume specificVolume) { diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index c154a74bbe..8b72d48a92 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -45,9 +45,9 @@ namespace UnitsNet IDivisionOperators, IDivisionOperators, IDivisionOperators, - IDivisionOperators, IMultiplyOperators, IMultiplyOperators, + IDivisionOperators, IMultiplyOperators, IDivisionOperators, IDivisionOperators, @@ -1040,12 +1040,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return Density.FromKilogramsPerCubicMeter(massFlow.KilogramsPerSecond / volumeFlow.CubicMetersPerSecond); } - /// Get from / . - public static MassFlux operator /(MassFlow massFlow, Area area) - { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); - } - /// Get from * . public static Mass operator *(MassFlow massFlow, Duration duration) { @@ -1064,6 +1058,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return Mass.FromKilograms(timeSpan.TotalSeconds * massFlow.KilogramsPerSecond); } + /// Get from / . + public static MassFlux operator /(MassFlow massFlow, Area area) + { + return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); + } + /// Get from * . public static Power operator *(MassFlow massFlow, SpecificEnergy specificEnergy) { diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index b35bad827c..3e29004ac2 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -42,9 +42,9 @@ namespace UnitsNet public readonly partial struct MolarMass : IArithmeticQuantity, #if NET7_0_OR_GREATER + IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, #endif IComparable, IComparable, @@ -656,6 +656,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Relational Operators + /// Get from * . + public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) + { + return Mass.FromGrams(molarMass.GramsPerMole * amountOfSubstance.Moles); + } + /// Get from * . public static MassConcentration operator *(MolarMass molarMass, Molarity molarity) { @@ -668,12 +674,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return MassFlow.FromKilogramsPerSecond(molarMass.KilogramsPerKilomole * molarFlow.KilomolesPerSecond); } - /// Get from * . - public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) - { - return Mass.FromGrams(molarMass.GramsPerMole * amountOfSubstance.Moles); - } - #endregion #region Equality / IComparable From 2b9d4561b12eefdf30c8442dcca4ac933751bff9 Mon Sep 17 00:00:00 2001 From: Muximize Date: Tue, 9 Jan 2024 01:36:27 +0100 Subject: [PATCH 11/12] Make casting decimal types neater --- CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 9da38e6b23..37810f81be 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -17,8 +17,6 @@ internal class QuantityGenerator : GeneratorBase private readonly string _valueType; private readonly Unit _baseUnit; - private readonly string[] _decimalTypes = { "BitRate", "Information", "Power" }; - public QuantityGenerator(Quantity quantity) { _quantity = quantity ?? throw new ArgumentNullException(nameof(quantity)); @@ -794,8 +792,8 @@ private void GenerateRelationalOperators() rightPart = "value"; } - var leftCast = _decimalTypes.Contains(relation.LeftQuantity.Name) ? "(double)" : ""; - var rightCast = _decimalTypes.Contains(relation.RightQuantity.Name) ? "(double)" : ""; + var leftCast = relation.LeftQuantity.ValueType is "decimal" ? "(double)" : string.Empty; + var rightCast = relation.RightQuantity.ValueType is "decimal" ? "(double)" : string.Empty; var expression = $"{leftCast}{leftPart} {relation.Operator} {rightCast}{rightPart}"; From f4231c1c14795b38d5403c992084de3b8e2766af Mon Sep 17 00:00:00 2001 From: Muximize Date: Tue, 9 Jan 2024 01:51:52 +0100 Subject: [PATCH 12/12] Clean up GenerateRelationalOperators a bit --- .../Generators/UnitsNetGen/QuantityGenerator.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 37810f81be..2875f84eff 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -761,12 +761,12 @@ private void GenerateRelationalOperators() var rightParameter = relation.RightQuantity.Name.ToCamelCase(); var rightConversionProperty = relation.RightUnit.PluralName; - if (relation.LeftQuantity.Name == "TimeSpan") + if (relation.LeftQuantity.Name is nameof(TimeSpan)) { leftConversionProperty = "Total" + leftConversionProperty; } - if (relation.RightQuantity.Name == "TimeSpan") + if (relation.RightQuantity.Name is nameof(TimeSpan)) { rightConversionProperty = "Total" + rightConversionProperty; } @@ -780,16 +780,14 @@ private void GenerateRelationalOperators() var leftPart = $"{leftParameter}.{leftConversionProperty}"; var rightPart = $"{rightParameter}.{rightConversionProperty}"; - if (leftParameter == "double") + if (leftParameter is "double") { - leftParameter = "value"; - leftPart = "value"; + leftParameter = leftPart = "value"; } - if (rightParameter == "double") + if (rightParameter is "double") { - rightParameter = "value"; - rightPart = "value"; + rightParameter = rightPart = "value"; } var leftCast = relation.LeftQuantity.ValueType is "decimal" ? "(double)" : string.Empty;