diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 5c9e7b67c1..a5bd6c3f77 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -152,60 +152,60 @@ private void GenerateQuantityInfo() /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class {quantityInfoClassName}: QuantityInfo<{_quantity.Name}, {_unitEnumName}> + private static class {quantityInfoClassName} {{"); Writer.WL($@" - /// - public {quantityInfoClassName}(string name, {_unitEnumName} baseUnit, IEnumerable> unitMappings, {_quantity.Name} zero, BaseDimensions baseDimensions, - QuantityFromDelegate<{_quantity.Name}, {_unitEnumName}> fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, {_quantity.Name}.RegisterDefaultConversions, unitAbbreviations) - {{ - }} - - /// - public {quantityInfoClassName}(string name, {_unitEnumName} baseUnit, IEnumerable> unitMappings, {_quantity.Name} zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, {_quantity.Name}.From, new ResourceManager(""UnitsNet.GeneratedCode.Resources.{_quantity.Name}"", typeof({_quantity.Name}).Assembly)) - {{ - }} - - /// - /// Creates a new instance of the class with the default settings for the {_quantity.Name} quantity. - /// - /// A new instance of the class with the default settings. - public static {quantityInfoClassName} CreateDefault() - {{ - return new {quantityInfoClassName}(nameof({_quantity.Name}), DefaultBaseUnit, GetDefaultMappings(), new {_quantity.Name}(0, DefaultBaseUnit), DefaultBaseDimensions); - }} - /// /// Creates a new instance of the class with the default settings for the {_quantity.Name} quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static {quantityInfoClassName} CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo<{_quantity.Name}, {_unitEnumName}> Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) {{ - return new {quantityInfoClassName}(nameof({_quantity.Name}), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new {_quantity.Name}(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = {_quantity.Name}Info.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo<{_quantity.Name}, {_unitEnumName}>( + name: nameof({_quantity.Name}), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new {_quantity.Name}(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); }} /// /// The for is {_quantity.BaseDimensions}. /// - public static BaseDimensions DefaultBaseDimensions {{ get; }} = {createDimensionsExpression}; + private static BaseDimensions DefaultBaseDimensions {{ get; }} = {createDimensionsExpression}; /// /// The default base unit of {_quantity.Name} is {_baseUnit.SingularName}. All conversions, as defined in the , go via this value. /// - public static {_unitEnumName} DefaultBaseUnit {{ get; }} = {_unitEnumName}.{_baseUnit.SingularName}; + private static {_unitEnumName} DefaultBaseUnit {{ get; }} = {_unitEnumName}.{_baseUnit.SingularName}; + + /// + /// The default resource manager for unit abbreviations of the {_quantity.Name} quantity. + /// + private static ResourceManager DefaultUnitAbbreviations {{ get; }} = new(""UnitsNet.GeneratedCode.Resources.{_quantity.Name}"", typeof({_quantity.Name}).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for {_quantity.Name}. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() {{"); foreach (Unit unit in _quantity.Units) @@ -247,7 +247,7 @@ private void GenerateStaticConstructor() static {_quantity.Name}() {{"); Writer.WL($@" - Info = {_quantity.Name}Info.CreateDefault(); + Info = {_quantity.Name}Info.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); }} diff --git a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs index 5e4266b7c4..bdddf3cff8 100644 --- a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AbsorbedDoseOfIonizingRadiationInfo: QuantityInfo + private static class AbsorbedDoseOfIonizingRadiationInfo { - /// - public AbsorbedDoseOfIonizingRadiationInfo(string name, AbsorbedDoseOfIonizingRadiationUnit baseUnit, IEnumerable> unitMappings, AbsorbedDoseOfIonizingRadiation zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, AbsorbedDoseOfIonizingRadiation.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AbsorbedDoseOfIonizingRadiationInfo(string name, AbsorbedDoseOfIonizingRadiationUnit baseUnit, IEnumerable> unitMappings, AbsorbedDoseOfIonizingRadiation zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, AbsorbedDoseOfIonizingRadiation.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.AbsorbedDoseOfIonizingRadiation", typeof(AbsorbedDoseOfIonizingRadiation).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the AbsorbedDoseOfIonizingRadiation quantity. - /// - /// A new instance of the class with the default settings. - public static AbsorbedDoseOfIonizingRadiationInfo CreateDefault() - { - return new AbsorbedDoseOfIonizingRadiationInfo(nameof(AbsorbedDoseOfIonizingRadiation), DefaultBaseUnit, GetDefaultMappings(), new AbsorbedDoseOfIonizingRadiation(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the AbsorbedDoseOfIonizingRadiation quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AbsorbedDoseOfIonizingRadiationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AbsorbedDoseOfIonizingRadiationInfo(nameof(AbsorbedDoseOfIonizingRadiation), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new AbsorbedDoseOfIonizingRadiation(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AbsorbedDoseOfIonizingRadiationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(AbsorbedDoseOfIonizingRadiation), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new AbsorbedDoseOfIonizingRadiation(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); /// /// The default base unit of AbsorbedDoseOfIonizingRadiation is Gray. All conversions, as defined in the , go via this value. /// - public static AbsorbedDoseOfIonizingRadiationUnit DefaultBaseUnit { get; } = AbsorbedDoseOfIonizingRadiationUnit.Gray; + private static AbsorbedDoseOfIonizingRadiationUnit DefaultBaseUnit { get; } = AbsorbedDoseOfIonizingRadiationUnit.Gray; + + /// + /// The default resource manager for unit abbreviations of the AbsorbedDoseOfIonizingRadiation quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.AbsorbedDoseOfIonizingRadiation", typeof(AbsorbedDoseOfIonizingRadiation).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for AbsorbedDoseOfIonizingRadiation. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AbsorbedDoseOfIonizingRadiationUnit.Centigray, "Centigray", "Centigrays", new BaseUnits(length: LengthUnit.Decimeter, time: DurationUnit.Second)); yield return new (AbsorbedDoseOfIonizingRadiationUnit.Femtogray, "Femtogray", "Femtograys", BaseUnits.Undefined); @@ -140,7 +140,7 @@ public static IEnumerable> G static AbsorbedDoseOfIonizingRadiation() { - Info = AbsorbedDoseOfIonizingRadiationInfo.CreateDefault(); + Info = AbsorbedDoseOfIonizingRadiationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 20efe14d95..70fff8ae3b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -69,59 +69,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AccelerationInfo: QuantityInfo + private static class AccelerationInfo { - /// - public AccelerationInfo(string name, AccelerationUnit baseUnit, IEnumerable> unitMappings, Acceleration zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Acceleration.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AccelerationInfo(string name, AccelerationUnit baseUnit, IEnumerable> unitMappings, Acceleration zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Acceleration.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Acceleration", typeof(Acceleration).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Acceleration quantity. - /// - /// A new instance of the class with the default settings. - public static AccelerationInfo CreateDefault() - { - return new AccelerationInfo(nameof(Acceleration), DefaultBaseUnit, GetDefaultMappings(), new Acceleration(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Acceleration quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AccelerationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AccelerationInfo(nameof(Acceleration), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Acceleration(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AccelerationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Acceleration), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Acceleration(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -2, 0, 0, 0, 0); /// /// The default base unit of Acceleration is MeterPerSecondSquared. All conversions, as defined in the , go via this value. /// - public static AccelerationUnit DefaultBaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; + private static AccelerationUnit DefaultBaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; + + /// + /// The default resource manager for unit abbreviations of the Acceleration quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Acceleration", typeof(Acceleration).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Acceleration. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AccelerationUnit.CentimeterPerSecondSquared, "CentimeterPerSecondSquared", "CentimetersPerSecondSquared", new BaseUnits(length: LengthUnit.Centimeter, time: DurationUnit.Second)); yield return new (AccelerationUnit.DecimeterPerSecondSquared, "DecimeterPerSecondSquared", "DecimetersPerSecondSquared", new BaseUnits(length: LengthUnit.Decimeter, time: DurationUnit.Second)); @@ -142,7 +142,7 @@ public static IEnumerable> GetDefaultMappings() static Acceleration() { - Info = AccelerationInfo.CreateDefault(); + Info = AccelerationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 161d381d26..187b815572 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -70,59 +70,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AmountOfSubstanceInfo: QuantityInfo + private static class AmountOfSubstanceInfo { - /// - public AmountOfSubstanceInfo(string name, AmountOfSubstanceUnit baseUnit, IEnumerable> unitMappings, AmountOfSubstance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, AmountOfSubstance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AmountOfSubstanceInfo(string name, AmountOfSubstanceUnit baseUnit, IEnumerable> unitMappings, AmountOfSubstance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, AmountOfSubstance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.AmountOfSubstance", typeof(AmountOfSubstance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the AmountOfSubstance quantity. - /// - /// A new instance of the class with the default settings. - public static AmountOfSubstanceInfo CreateDefault() - { - return new AmountOfSubstanceInfo(nameof(AmountOfSubstance), DefaultBaseUnit, GetDefaultMappings(), new AmountOfSubstance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the AmountOfSubstance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AmountOfSubstanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AmountOfSubstanceInfo(nameof(AmountOfSubstance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new AmountOfSubstance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AmountOfSubstanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(AmountOfSubstance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new AmountOfSubstance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [N]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 0, 1, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 0, 1, 0); /// /// The default base unit of AmountOfSubstance is Mole. All conversions, as defined in the , go via this value. /// - public static AmountOfSubstanceUnit DefaultBaseUnit { get; } = AmountOfSubstanceUnit.Mole; + private static AmountOfSubstanceUnit DefaultBaseUnit { get; } = AmountOfSubstanceUnit.Mole; + + /// + /// The default resource manager for unit abbreviations of the AmountOfSubstance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.AmountOfSubstance", typeof(AmountOfSubstance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for AmountOfSubstance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AmountOfSubstanceUnit.Centimole, "Centimole", "Centimoles", new BaseUnits(amount: AmountOfSubstanceUnit.Centimole)); yield return new (AmountOfSubstanceUnit.CentipoundMole, "CentipoundMole", "CentipoundMoles", new BaseUnits(amount: AmountOfSubstanceUnit.CentipoundMole)); @@ -146,7 +146,7 @@ public static IEnumerable> GetDefaultMappi static AmountOfSubstance() { - Info = AmountOfSubstanceInfo.CreateDefault(); + Info = AmountOfSubstanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index c6e25b5989..ed35806958 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AmplitudeRatioInfo: QuantityInfo + private static class AmplitudeRatioInfo { - /// - public AmplitudeRatioInfo(string name, AmplitudeRatioUnit baseUnit, IEnumerable> unitMappings, AmplitudeRatio zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, AmplitudeRatio.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AmplitudeRatioInfo(string name, AmplitudeRatioUnit baseUnit, IEnumerable> unitMappings, AmplitudeRatio zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, AmplitudeRatio.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.AmplitudeRatio", typeof(AmplitudeRatio).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the AmplitudeRatio quantity. - /// - /// A new instance of the class with the default settings. - public static AmplitudeRatioInfo CreateDefault() - { - return new AmplitudeRatioInfo(nameof(AmplitudeRatio), DefaultBaseUnit, GetDefaultMappings(), new AmplitudeRatio(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the AmplitudeRatio quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AmplitudeRatioInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AmplitudeRatioInfo(nameof(AmplitudeRatio), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new AmplitudeRatio(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AmplitudeRatioInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(AmplitudeRatio), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new AmplitudeRatio(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of AmplitudeRatio is DecibelVolt. All conversions, as defined in the , go via this value. /// - public static AmplitudeRatioUnit DefaultBaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; + private static AmplitudeRatioUnit DefaultBaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; + + /// + /// The default resource manager for unit abbreviations of the AmplitudeRatio quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.AmplitudeRatio", typeof(AmplitudeRatio).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for AmplitudeRatio. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AmplitudeRatioUnit.DecibelMicrovolt, "DecibelMicrovolt", "DecibelMicrovolts", BaseUnits.Undefined); yield return new (AmplitudeRatioUnit.DecibelMillivolt, "DecibelMillivolt", "DecibelMillivolts", BaseUnits.Undefined); @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings static AmplitudeRatio() { - Info = AmplitudeRatioInfo.CreateDefault(); + Info = AmplitudeRatioInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index ab3c77211a..f241608b34 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -67,59 +67,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AngleInfo: QuantityInfo + private static class AngleInfo { - /// - public AngleInfo(string name, AngleUnit baseUnit, IEnumerable> unitMappings, Angle zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Angle.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AngleInfo(string name, AngleUnit baseUnit, IEnumerable> unitMappings, Angle zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Angle.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Angle", typeof(Angle).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Angle quantity. - /// - /// A new instance of the class with the default settings. - public static AngleInfo CreateDefault() - { - return new AngleInfo(nameof(Angle), DefaultBaseUnit, GetDefaultMappings(), new Angle(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Angle quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AngleInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AngleInfo(nameof(Angle), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Angle(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AngleInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Angle), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Angle(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of Angle is Radian. All conversions, as defined in the , go via this value. /// - public static AngleUnit DefaultBaseUnit { get; } = AngleUnit.Radian; + private static AngleUnit DefaultBaseUnit { get; } = AngleUnit.Radian; + + /// + /// The default resource manager for unit abbreviations of the Angle quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Angle", typeof(Angle).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Angle. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AngleUnit.Arcminute, "Arcminute", "Arcminutes", BaseUnits.Undefined); yield return new (AngleUnit.Arcsecond, "Arcsecond", "Arcseconds", BaseUnits.Undefined); @@ -141,7 +141,7 @@ public static IEnumerable> GetDefaultMappings() static Angle() { - Info = AngleInfo.CreateDefault(); + Info = AngleInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 24fde31e8b..304e137381 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -80,59 +80,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AreaInfo: QuantityInfo + private static class AreaInfo { - /// - public AreaInfo(string name, AreaUnit baseUnit, IEnumerable> unitMappings, Area zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Area.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AreaInfo(string name, AreaUnit baseUnit, IEnumerable> unitMappings, Area zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Area.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Area", typeof(Area).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Area quantity. - /// - /// A new instance of the class with the default settings. - public static AreaInfo CreateDefault() - { - return new AreaInfo(nameof(Area), DefaultBaseUnit, GetDefaultMappings(), new Area(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Area quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AreaInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AreaInfo(nameof(Area), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Area(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AreaInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Area), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Area(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); /// /// The default base unit of Area is SquareMeter. All conversions, as defined in the , go via this value. /// - public static AreaUnit DefaultBaseUnit { get; } = AreaUnit.SquareMeter; + private static AreaUnit DefaultBaseUnit { get; } = AreaUnit.SquareMeter; + + /// + /// The default resource manager for unit abbreviations of the Area quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Area", typeof(Area).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Area. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AreaUnit.Acre, "Acre", "Acres", BaseUnits.Undefined); yield return new (AreaUnit.Hectare, "Hectare", "Hectares", BaseUnits.Undefined); @@ -153,7 +153,7 @@ public static IEnumerable> GetDefaultMappings() static Area() { - Info = AreaInfo.CreateDefault(); + Info = AreaInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index e24c9123f7..0d93e0f4af 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AreaDensityInfo: QuantityInfo + private static class AreaDensityInfo { - /// - public AreaDensityInfo(string name, AreaDensityUnit baseUnit, IEnumerable> unitMappings, AreaDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, AreaDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AreaDensityInfo(string name, AreaDensityUnit baseUnit, IEnumerable> unitMappings, AreaDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, AreaDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.AreaDensity", typeof(AreaDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the AreaDensity quantity. - /// - /// A new instance of the class with the default settings. - public static AreaDensityInfo CreateDefault() - { - return new AreaDensityInfo(nameof(AreaDensity), DefaultBaseUnit, GetDefaultMappings(), new AreaDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the AreaDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AreaDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AreaDensityInfo(nameof(AreaDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new AreaDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AreaDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(AreaDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new AreaDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 1, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 1, 0, 0, 0, 0, 0); /// /// The default base unit of AreaDensity is KilogramPerSquareMeter. All conversions, as defined in the , go via this value. /// - public static AreaDensityUnit DefaultBaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; + private static AreaDensityUnit DefaultBaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the AreaDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.AreaDensity", typeof(AreaDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for AreaDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AreaDensityUnit.GramPerSquareMeter, "GramPerSquareMeter", "GramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Gram)); yield return new (AreaDensityUnit.KilogramPerSquareMeter, "KilogramPerSquareMeter", "KilogramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefaultMappings() static AreaDensity() { - Info = AreaDensityInfo.CreateDefault(); + Info = AreaDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index efeb3d35b7..9ff9da5be8 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -66,59 +66,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class AreaMomentOfInertiaInfo: QuantityInfo + private static class AreaMomentOfInertiaInfo { - /// - public AreaMomentOfInertiaInfo(string name, AreaMomentOfInertiaUnit baseUnit, IEnumerable> unitMappings, AreaMomentOfInertia zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, AreaMomentOfInertia.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public AreaMomentOfInertiaInfo(string name, AreaMomentOfInertiaUnit baseUnit, IEnumerable> unitMappings, AreaMomentOfInertia zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, AreaMomentOfInertia.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.AreaMomentOfInertia", typeof(AreaMomentOfInertia).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the AreaMomentOfInertia quantity. - /// - /// A new instance of the class with the default settings. - public static AreaMomentOfInertiaInfo CreateDefault() - { - return new AreaMomentOfInertiaInfo(nameof(AreaMomentOfInertia), DefaultBaseUnit, GetDefaultMappings(), new AreaMomentOfInertia(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the AreaMomentOfInertia quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static AreaMomentOfInertiaInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new AreaMomentOfInertiaInfo(nameof(AreaMomentOfInertia), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new AreaMomentOfInertia(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = AreaMomentOfInertiaInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(AreaMomentOfInertia), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new AreaMomentOfInertia(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^4]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(4, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(4, 0, 0, 0, 0, 0, 0); /// /// The default base unit of AreaMomentOfInertia is MeterToTheFourth. All conversions, as defined in the , go via this value. /// - public static AreaMomentOfInertiaUnit DefaultBaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; + private static AreaMomentOfInertiaUnit DefaultBaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; + + /// + /// The default resource manager for unit abbreviations of the AreaMomentOfInertia quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.AreaMomentOfInertia", typeof(AreaMomentOfInertia).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for AreaMomentOfInertia. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (AreaMomentOfInertiaUnit.CentimeterToTheFourth, "CentimeterToTheFourth", "CentimetersToTheFourth", new BaseUnits(length: LengthUnit.Centimeter)); yield return new (AreaMomentOfInertiaUnit.DecimeterToTheFourth, "DecimeterToTheFourth", "DecimetersToTheFourth", new BaseUnits(length: LengthUnit.Decimeter)); @@ -131,7 +131,7 @@ public static IEnumerable> GetDefaultMap static AreaMomentOfInertia() { - Info = AreaMomentOfInertiaInfo.CreateDefault(); + Info = AreaMomentOfInertiaInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 8fdf7928b1..2833f2a4eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class BitRateInfo: QuantityInfo + private static class BitRateInfo { - /// - public BitRateInfo(string name, BitRateUnit baseUnit, IEnumerable> unitMappings, BitRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, BitRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public BitRateInfo(string name, BitRateUnit baseUnit, IEnumerable> unitMappings, BitRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, BitRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.BitRate", typeof(BitRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the BitRate quantity. - /// - /// A new instance of the class with the default settings. - public static BitRateInfo CreateDefault() - { - return new BitRateInfo(nameof(BitRate), DefaultBaseUnit, GetDefaultMappings(), new BitRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the BitRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static BitRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new BitRateInfo(nameof(BitRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new BitRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = BitRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(BitRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new BitRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); /// /// The default base unit of BitRate is BitPerSecond. All conversions, as defined in the , go via this value. /// - public static BitRateUnit DefaultBaseUnit { get; } = BitRateUnit.BitPerSecond; + private static BitRateUnit DefaultBaseUnit { get; } = BitRateUnit.BitPerSecond; + + /// + /// The default resource manager for unit abbreviations of the BitRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.BitRate", typeof(BitRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for BitRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (BitRateUnit.BitPerSecond, "BitPerSecond", "BitsPerSecond", new BaseUnits(time: DurationUnit.Second)); yield return new (BitRateUnit.BytePerSecond, "BytePerSecond", "BytesPerSecond", BaseUnits.Undefined); @@ -163,7 +163,7 @@ public static IEnumerable> GetDefaultMappings() static BitRate() { - Info = BitRateInfo.CreateDefault(); + Info = BitRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 2e50935bc8..265189d5fc 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -66,59 +66,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class BrakeSpecificFuelConsumptionInfo: QuantityInfo + private static class BrakeSpecificFuelConsumptionInfo { - /// - public BrakeSpecificFuelConsumptionInfo(string name, BrakeSpecificFuelConsumptionUnit baseUnit, IEnumerable> unitMappings, BrakeSpecificFuelConsumption zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, BrakeSpecificFuelConsumption.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public BrakeSpecificFuelConsumptionInfo(string name, BrakeSpecificFuelConsumptionUnit baseUnit, IEnumerable> unitMappings, BrakeSpecificFuelConsumption zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, BrakeSpecificFuelConsumption.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.BrakeSpecificFuelConsumption", typeof(BrakeSpecificFuelConsumption).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the BrakeSpecificFuelConsumption quantity. - /// - /// A new instance of the class with the default settings. - public static BrakeSpecificFuelConsumptionInfo CreateDefault() - { - return new BrakeSpecificFuelConsumptionInfo(nameof(BrakeSpecificFuelConsumption), DefaultBaseUnit, GetDefaultMappings(), new BrakeSpecificFuelConsumption(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the BrakeSpecificFuelConsumption quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static BrakeSpecificFuelConsumptionInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new BrakeSpecificFuelConsumptionInfo(nameof(BrakeSpecificFuelConsumption), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new BrakeSpecificFuelConsumption(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = BrakeSpecificFuelConsumptionInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(BrakeSpecificFuelConsumption), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new BrakeSpecificFuelConsumption(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^2][L^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 2, 0, 0, 0, 0); /// /// The default base unit of BrakeSpecificFuelConsumption is KilogramPerJoule. All conversions, as defined in the , go via this value. /// - public static BrakeSpecificFuelConsumptionUnit DefaultBaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; + private static BrakeSpecificFuelConsumptionUnit DefaultBaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; + + /// + /// The default resource manager for unit abbreviations of the BrakeSpecificFuelConsumption quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.BrakeSpecificFuelConsumption", typeof(BrakeSpecificFuelConsumption).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for BrakeSpecificFuelConsumption. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, "GramPerKiloWattHour", "GramsPerKiloWattHour", BaseUnits.Undefined); yield return new (BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, "KilogramPerJoule", "KilogramsPerJoule", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)); @@ -128,7 +128,7 @@ public static IEnumerable> GetD static BrakeSpecificFuelConsumption() { - Info = BrakeSpecificFuelConsumptionInfo.CreateDefault(); + Info = BrakeSpecificFuelConsumptionInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 490de985e2..1383c1e40e 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class CoefficientOfThermalExpansionInfo: QuantityInfo + private static class CoefficientOfThermalExpansionInfo { - /// - public CoefficientOfThermalExpansionInfo(string name, CoefficientOfThermalExpansionUnit baseUnit, IEnumerable> unitMappings, CoefficientOfThermalExpansion zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, CoefficientOfThermalExpansion.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public CoefficientOfThermalExpansionInfo(string name, CoefficientOfThermalExpansionUnit baseUnit, IEnumerable> unitMappings, CoefficientOfThermalExpansion zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, CoefficientOfThermalExpansion.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.CoefficientOfThermalExpansion", typeof(CoefficientOfThermalExpansion).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the CoefficientOfThermalExpansion quantity. - /// - /// A new instance of the class with the default settings. - public static CoefficientOfThermalExpansionInfo CreateDefault() - { - return new CoefficientOfThermalExpansionInfo(nameof(CoefficientOfThermalExpansion), DefaultBaseUnit, GetDefaultMappings(), new CoefficientOfThermalExpansion(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the CoefficientOfThermalExpansion quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static CoefficientOfThermalExpansionInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new CoefficientOfThermalExpansionInfo(nameof(CoefficientOfThermalExpansion), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new CoefficientOfThermalExpansion(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = CoefficientOfThermalExpansionInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(CoefficientOfThermalExpansion), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new CoefficientOfThermalExpansion(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [Θ^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, -1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, -1, 0, 0); /// /// The default base unit of CoefficientOfThermalExpansion is PerKelvin. All conversions, as defined in the , go via this value. /// - public static CoefficientOfThermalExpansionUnit DefaultBaseUnit { get; } = CoefficientOfThermalExpansionUnit.PerKelvin; + private static CoefficientOfThermalExpansionUnit DefaultBaseUnit { get; } = CoefficientOfThermalExpansionUnit.PerKelvin; + + /// + /// The default resource manager for unit abbreviations of the CoefficientOfThermalExpansion quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.CoefficientOfThermalExpansion", typeof(CoefficientOfThermalExpansion).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for CoefficientOfThermalExpansion. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (CoefficientOfThermalExpansionUnit.PerDegreeCelsius, "PerDegreeCelsius", "PerDegreeCelsius", new BaseUnits(temperature: TemperatureUnit.DegreeCelsius)); yield return new (CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit, "PerDegreeFahrenheit", "PerDegreeFahrenheit", new BaseUnits(temperature: TemperatureUnit.DegreeFahrenheit)); @@ -130,7 +130,7 @@ public static IEnumerable> Get static CoefficientOfThermalExpansion() { - Info = CoefficientOfThermalExpansionInfo.CreateDefault(); + Info = CoefficientOfThermalExpansionInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index c89d1dd991..8bb135aeb3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class CompressibilityInfo: QuantityInfo + private static class CompressibilityInfo { - /// - public CompressibilityInfo(string name, CompressibilityUnit baseUnit, IEnumerable> unitMappings, Compressibility zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Compressibility.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public CompressibilityInfo(string name, CompressibilityUnit baseUnit, IEnumerable> unitMappings, Compressibility zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Compressibility.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Compressibility", typeof(Compressibility).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Compressibility quantity. - /// - /// A new instance of the class with the default settings. - public static CompressibilityInfo CreateDefault() - { - return new CompressibilityInfo(nameof(Compressibility), DefaultBaseUnit, GetDefaultMappings(), new Compressibility(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Compressibility quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static CompressibilityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new CompressibilityInfo(nameof(Compressibility), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Compressibility(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = CompressibilityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Compressibility), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Compressibility(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^2][L][M^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, -1, 2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, -1, 2, 0, 0, 0, 0); /// /// The default base unit of Compressibility is InversePascal. All conversions, as defined in the , go via this value. /// - public static CompressibilityUnit DefaultBaseUnit { get; } = CompressibilityUnit.InversePascal; + private static CompressibilityUnit DefaultBaseUnit { get; } = CompressibilityUnit.InversePascal; + + /// + /// The default resource manager for unit abbreviations of the Compressibility quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Compressibility", typeof(Compressibility).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Compressibility. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (CompressibilityUnit.InverseAtmosphere, "InverseAtmosphere", "InverseAtmospheres", BaseUnits.Undefined); yield return new (CompressibilityUnit.InverseBar, "InverseBar", "InverseBars", BaseUnits.Undefined); @@ -128,7 +128,7 @@ public static IEnumerable> GetDefaultMapping static Compressibility() { - Info = CompressibilityInfo.CreateDefault(); + Info = CompressibilityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index aeb587fe24..f4f95b95dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -74,59 +74,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class DensityInfo: QuantityInfo + private static class DensityInfo { - /// - public DensityInfo(string name, DensityUnit baseUnit, IEnumerable> unitMappings, Density zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Density.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public DensityInfo(string name, DensityUnit baseUnit, IEnumerable> unitMappings, Density zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Density.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Density", typeof(Density).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Density quantity. - /// - /// A new instance of the class with the default settings. - public static DensityInfo CreateDefault() - { - return new DensityInfo(nameof(Density), DefaultBaseUnit, GetDefaultMappings(), new Density(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Density quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static DensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new DensityInfo(nameof(Density), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Density(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = DensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Density), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Density(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-3][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); /// /// The default base unit of Density is KilogramPerCubicMeter. All conversions, as defined in the , go via this value. /// - public static DensityUnit DefaultBaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; + private static DensityUnit DefaultBaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the Density quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Density", typeof(Density).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Density. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (DensityUnit.CentigramPerDeciliter, "CentigramPerDeciliter", "CentigramsPerDeciliter", BaseUnits.Undefined); yield return new (DensityUnit.CentigramPerLiter, "CentigramPerLiter", "CentigramsPerLiter", new BaseUnits(length: LengthUnit.Decimeter, mass: MassUnit.Centigram)); @@ -189,7 +189,7 @@ public static IEnumerable> GetDefaultMappings() static Density() { - Info = DensityInfo.CreateDefault(); + Info = DensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs index 20b74574c9..d8afb47dd8 100644 --- a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class DoseAreaProductInfo: QuantityInfo + private static class DoseAreaProductInfo { - /// - public DoseAreaProductInfo(string name, DoseAreaProductUnit baseUnit, IEnumerable> unitMappings, DoseAreaProduct zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, DoseAreaProduct.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public DoseAreaProductInfo(string name, DoseAreaProductUnit baseUnit, IEnumerable> unitMappings, DoseAreaProduct zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, DoseAreaProduct.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.DoseAreaProduct", typeof(DoseAreaProduct).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the DoseAreaProduct quantity. - /// - /// A new instance of the class with the default settings. - public static DoseAreaProductInfo CreateDefault() - { - return new DoseAreaProductInfo(nameof(DoseAreaProduct), DefaultBaseUnit, GetDefaultMappings(), new DoseAreaProduct(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the DoseAreaProduct quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static DoseAreaProductInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new DoseAreaProductInfo(nameof(DoseAreaProduct), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new DoseAreaProduct(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = DoseAreaProductInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(DoseAreaProduct), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new DoseAreaProduct(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^4]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(4, 0, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(4, 0, -2, 0, 0, 0, 0); /// /// The default base unit of DoseAreaProduct is GraySquareMeter. All conversions, as defined in the , go via this value. /// - public static DoseAreaProductUnit DefaultBaseUnit { get; } = DoseAreaProductUnit.GraySquareMeter; + private static DoseAreaProductUnit DefaultBaseUnit { get; } = DoseAreaProductUnit.GraySquareMeter; + + /// + /// The default resource manager for unit abbreviations of the DoseAreaProduct quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.DoseAreaProduct", typeof(DoseAreaProduct).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for DoseAreaProduct. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (DoseAreaProductUnit.CentigraySquareCentimeter, "CentigraySquareCentimeter", "CentigraySquareCentimeters", BaseUnits.Undefined); yield return new (DoseAreaProductUnit.CentigraySquareDecimeter, "CentigraySquareDecimeter", "CentigraySquareDecimeters", BaseUnits.Undefined); @@ -144,7 +144,7 @@ public static IEnumerable> GetDefaultMapping static DoseAreaProduct() { - Info = DoseAreaProductInfo.CreateDefault(); + Info = DoseAreaProductInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 5e3cf9043d..e4405c4fe0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -79,59 +79,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class DurationInfo: QuantityInfo + private static class DurationInfo { - /// - public DurationInfo(string name, DurationUnit baseUnit, IEnumerable> unitMappings, Duration zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Duration.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public DurationInfo(string name, DurationUnit baseUnit, IEnumerable> unitMappings, Duration zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Duration.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Duration", typeof(Duration).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Duration quantity. - /// - /// A new instance of the class with the default settings. - public static DurationInfo CreateDefault() - { - return new DurationInfo(nameof(Duration), DefaultBaseUnit, GetDefaultMappings(), new Duration(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Duration quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static DurationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new DurationInfo(nameof(Duration), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Duration(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = DurationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Duration), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Duration(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 1, 0, 0, 0, 0); /// /// The default base unit of Duration is Second. All conversions, as defined in the , go via this value. /// - public static DurationUnit DefaultBaseUnit { get; } = DurationUnit.Second; + private static DurationUnit DefaultBaseUnit { get; } = DurationUnit.Second; + + /// + /// The default resource manager for unit abbreviations of the Duration quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Duration", typeof(Duration).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Duration. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (DurationUnit.Day, "Day", "Days", new BaseUnits(time: DurationUnit.Day)); yield return new (DurationUnit.Hour, "Hour", "Hours", new BaseUnits(time: DurationUnit.Hour)); @@ -150,7 +150,7 @@ public static IEnumerable> GetDefaultMappings() static Duration() { - Info = DurationInfo.CreateDefault(); + Info = DurationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 5978cb0371..a4c655a7d6 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -69,59 +69,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class DynamicViscosityInfo: QuantityInfo + private static class DynamicViscosityInfo { - /// - public DynamicViscosityInfo(string name, DynamicViscosityUnit baseUnit, IEnumerable> unitMappings, DynamicViscosity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, DynamicViscosity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public DynamicViscosityInfo(string name, DynamicViscosityUnit baseUnit, IEnumerable> unitMappings, DynamicViscosity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, DynamicViscosity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.DynamicViscosity", typeof(DynamicViscosity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the DynamicViscosity quantity. - /// - /// A new instance of the class with the default settings. - public static DynamicViscosityInfo CreateDefault() - { - return new DynamicViscosityInfo(nameof(DynamicViscosity), DefaultBaseUnit, GetDefaultMappings(), new DynamicViscosity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the DynamicViscosity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static DynamicViscosityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new DynamicViscosityInfo(nameof(DynamicViscosity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new DynamicViscosity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = DynamicViscosityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(DynamicViscosity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new DynamicViscosity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0); /// /// The default base unit of DynamicViscosity is NewtonSecondPerMeterSquared. All conversions, as defined in the , go via this value. /// - public static DynamicViscosityUnit DefaultBaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; + private static DynamicViscosityUnit DefaultBaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; + + /// + /// The default resource manager for unit abbreviations of the DynamicViscosity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.DynamicViscosity", typeof(DynamicViscosity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for DynamicViscosity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (DynamicViscosityUnit.Centipoise, "Centipoise", "Centipoise", BaseUnits.Undefined); yield return new (DynamicViscosityUnit.MicropascalSecond, "MicropascalSecond", "MicropascalSeconds", BaseUnits.Undefined); @@ -138,7 +138,7 @@ public static IEnumerable> GetDefaultMappin static DynamicViscosity() { - Info = DynamicViscosityInfo.CreateDefault(); + Info = DynamicViscosityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index d508beeddc..7d91683dc1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -66,59 +66,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricAdmittanceInfo: QuantityInfo + private static class ElectricAdmittanceInfo { - /// - public ElectricAdmittanceInfo(string name, ElectricAdmittanceUnit baseUnit, IEnumerable> unitMappings, ElectricAdmittance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricAdmittance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricAdmittanceInfo(string name, ElectricAdmittanceUnit baseUnit, IEnumerable> unitMappings, ElectricAdmittance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricAdmittance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricAdmittance", typeof(ElectricAdmittance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricAdmittance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricAdmittanceInfo CreateDefault() - { - return new ElectricAdmittanceInfo(nameof(ElectricAdmittance), DefaultBaseUnit, GetDefaultMappings(), new ElectricAdmittance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricAdmittance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricAdmittanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricAdmittanceInfo(nameof(ElectricAdmittance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricAdmittance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricAdmittanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricAdmittance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricAdmittance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^3][L^-2][M^-1][I^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); /// /// The default base unit of ElectricAdmittance is Siemens. All conversions, as defined in the , go via this value. /// - public static ElectricAdmittanceUnit DefaultBaseUnit { get; } = ElectricAdmittanceUnit.Siemens; + private static ElectricAdmittanceUnit DefaultBaseUnit { get; } = ElectricAdmittanceUnit.Siemens; + + /// + /// The default resource manager for unit abbreviations of the ElectricAdmittance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricAdmittance", typeof(ElectricAdmittance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricAdmittance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricAdmittanceUnit.Gigamho, "Gigamho", "Gigamhos", BaseUnits.Undefined); yield return new (ElectricAdmittanceUnit.Gigasiemens, "Gigasiemens", "Gigasiemens", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Microgram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -141,7 +141,7 @@ public static IEnumerable> GetDefaultMapp static ElectricAdmittance() { - Info = ElectricAdmittanceInfo.CreateDefault(); + Info = ElectricAdmittanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs index cb89f9385b..1c01851619 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricApparentEnergyInfo: QuantityInfo + private static class ElectricApparentEnergyInfo { - /// - public ElectricApparentEnergyInfo(string name, ElectricApparentEnergyUnit baseUnit, IEnumerable> unitMappings, ElectricApparentEnergy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricApparentEnergy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricApparentEnergyInfo(string name, ElectricApparentEnergyUnit baseUnit, IEnumerable> unitMappings, ElectricApparentEnergy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricApparentEnergy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricApparentEnergy", typeof(ElectricApparentEnergy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricApparentEnergy quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricApparentEnergyInfo CreateDefault() - { - return new ElectricApparentEnergyInfo(nameof(ElectricApparentEnergy), DefaultBaseUnit, GetDefaultMappings(), new ElectricApparentEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricApparentEnergy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricApparentEnergyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricApparentEnergyInfo(nameof(ElectricApparentEnergy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricApparentEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricApparentEnergyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricApparentEnergy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricApparentEnergy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); /// /// The default base unit of ElectricApparentEnergy is VoltampereHour. All conversions, as defined in the , go via this value. /// - public static ElectricApparentEnergyUnit DefaultBaseUnit { get; } = ElectricApparentEnergyUnit.VoltampereHour; + private static ElectricApparentEnergyUnit DefaultBaseUnit { get; } = ElectricApparentEnergyUnit.VoltampereHour; + + /// + /// The default resource manager for unit abbreviations of the ElectricApparentEnergy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricApparentEnergy", typeof(ElectricApparentEnergy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricApparentEnergy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricApparentEnergyUnit.KilovoltampereHour, "KilovoltampereHour", "KilovoltampereHours", BaseUnits.Undefined); yield return new (ElectricApparentEnergyUnit.MegavoltampereHour, "MegavoltampereHour", "MegavoltampereHours", BaseUnits.Undefined); @@ -124,7 +124,7 @@ public static IEnumerable> GetDefault static ElectricApparentEnergy() { - Info = ElectricApparentEnergyInfo.CreateDefault(); + Info = ElectricApparentEnergyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs index 6cb8782f77..796a3c9272 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricApparentPowerInfo: QuantityInfo + private static class ElectricApparentPowerInfo { - /// - public ElectricApparentPowerInfo(string name, ElectricApparentPowerUnit baseUnit, IEnumerable> unitMappings, ElectricApparentPower zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricApparentPower.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricApparentPowerInfo(string name, ElectricApparentPowerUnit baseUnit, IEnumerable> unitMappings, ElectricApparentPower zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricApparentPower.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricApparentPower", typeof(ElectricApparentPower).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricApparentPower quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricApparentPowerInfo CreateDefault() - { - return new ElectricApparentPowerInfo(nameof(ElectricApparentPower), DefaultBaseUnit, GetDefaultMappings(), new ElectricApparentPower(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricApparentPower quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricApparentPowerInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricApparentPowerInfo(nameof(ElectricApparentPower), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricApparentPower(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricApparentPowerInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricApparentPower), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricApparentPower(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); /// /// The default base unit of ElectricApparentPower is Voltampere. All conversions, as defined in the , go via this value. /// - public static ElectricApparentPowerUnit DefaultBaseUnit { get; } = ElectricApparentPowerUnit.Voltampere; + private static ElectricApparentPowerUnit DefaultBaseUnit { get; } = ElectricApparentPowerUnit.Voltampere; + + /// + /// The default resource manager for unit abbreviations of the ElectricApparentPower quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricApparentPower", typeof(ElectricApparentPower).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricApparentPower. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricApparentPowerUnit.Gigavoltampere, "Gigavoltampere", "Gigavoltamperes", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Millisecond)); yield return new (ElectricApparentPowerUnit.Kilovoltampere, "Kilovoltampere", "Kilovoltamperes", BaseUnits.Undefined); @@ -130,7 +130,7 @@ public static IEnumerable> GetDefaultM static ElectricApparentPower() { - Info = ElectricApparentPowerInfo.CreateDefault(); + Info = ElectricApparentPowerInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs index f9b5484b7c..8aafce5bc1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricCapacitanceInfo: QuantityInfo + private static class ElectricCapacitanceInfo { - /// - public ElectricCapacitanceInfo(string name, ElectricCapacitanceUnit baseUnit, IEnumerable> unitMappings, ElectricCapacitance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricCapacitance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricCapacitanceInfo(string name, ElectricCapacitanceUnit baseUnit, IEnumerable> unitMappings, ElectricCapacitance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricCapacitance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricCapacitance", typeof(ElectricCapacitance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricCapacitance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricCapacitanceInfo CreateDefault() - { - return new ElectricCapacitanceInfo(nameof(ElectricCapacitance), DefaultBaseUnit, GetDefaultMappings(), new ElectricCapacitance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricCapacitance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricCapacitanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricCapacitanceInfo(nameof(ElectricCapacitance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricCapacitance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricCapacitanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricCapacitance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricCapacitance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^4][L^-2][M^-1][I^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 4, 2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 4, 2, 0, 0, 0); /// /// The default base unit of ElectricCapacitance is Farad. All conversions, as defined in the , go via this value. /// - public static ElectricCapacitanceUnit DefaultBaseUnit { get; } = ElectricCapacitanceUnit.Farad; + private static ElectricCapacitanceUnit DefaultBaseUnit { get; } = ElectricCapacitanceUnit.Farad; + + /// + /// The default resource manager for unit abbreviations of the ElectricCapacitance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricCapacitance", typeof(ElectricCapacitance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricCapacitance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricCapacitanceUnit.Farad, "Farad", "Farads", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricCapacitanceUnit.Kilofarad, "Kilofarad", "Kilofarads", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Gram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -131,7 +131,7 @@ public static IEnumerable> GetDefaultMap static ElectricCapacitance() { - Info = ElectricCapacitanceInfo.CreateDefault(); + Info = ElectricCapacitanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index b9d9f288be..17f2719b83 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -70,59 +70,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricChargeInfo: QuantityInfo + private static class ElectricChargeInfo { - /// - public ElectricChargeInfo(string name, ElectricChargeUnit baseUnit, IEnumerable> unitMappings, ElectricCharge zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricCharge.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricChargeInfo(string name, ElectricChargeUnit baseUnit, IEnumerable> unitMappings, ElectricCharge zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricCharge.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricCharge", typeof(ElectricCharge).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricCharge quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricChargeInfo CreateDefault() - { - return new ElectricChargeInfo(nameof(ElectricCharge), DefaultBaseUnit, GetDefaultMappings(), new ElectricCharge(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricCharge quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricChargeInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricChargeInfo(nameof(ElectricCharge), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricCharge(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricChargeInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricCharge), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricCharge(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T][I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 1, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 1, 1, 0, 0, 0); /// /// The default base unit of ElectricCharge is Coulomb. All conversions, as defined in the , go via this value. /// - public static ElectricChargeUnit DefaultBaseUnit { get; } = ElectricChargeUnit.Coulomb; + private static ElectricChargeUnit DefaultBaseUnit { get; } = ElectricChargeUnit.Coulomb; + + /// + /// The default resource manager for unit abbreviations of the ElectricCharge quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricCharge", typeof(ElectricCharge).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricCharge. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricChargeUnit.AmpereHour, "AmpereHour", "AmpereHours", new BaseUnits(time: DurationUnit.Hour, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricChargeUnit.Coulomb, "Coulomb", "Coulombs", new BaseUnits(time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -140,7 +140,7 @@ public static IEnumerable> GetDefaultMappings static ElectricCharge() { - Info = ElectricChargeInfo.CreateDefault(); + Info = ElectricChargeInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index ed0a8d529d..033b274272 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricChargeDensityInfo: QuantityInfo + private static class ElectricChargeDensityInfo { - /// - public ElectricChargeDensityInfo(string name, ElectricChargeDensityUnit baseUnit, IEnumerable> unitMappings, ElectricChargeDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricChargeDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricChargeDensityInfo(string name, ElectricChargeDensityUnit baseUnit, IEnumerable> unitMappings, ElectricChargeDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricChargeDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricChargeDensity", typeof(ElectricChargeDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricChargeDensity quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricChargeDensityInfo CreateDefault() - { - return new ElectricChargeDensityInfo(nameof(ElectricChargeDensity), DefaultBaseUnit, GetDefaultMappings(), new ElectricChargeDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricChargeDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricChargeDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricChargeDensityInfo(nameof(ElectricChargeDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricChargeDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricChargeDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricChargeDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricChargeDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T][L^-3][I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 0, 1, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 0, 1, 1, 0, 0, 0); /// /// The default base unit of ElectricChargeDensity is CoulombPerCubicMeter. All conversions, as defined in the , go via this value. /// - public static ElectricChargeDensityUnit DefaultBaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; + private static ElectricChargeDensityUnit DefaultBaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the ElectricChargeDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricChargeDensity", typeof(ElectricChargeDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricChargeDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricChargeDensityUnit.CoulombPerCubicMeter, "CoulombPerCubicMeter", "CoulombsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultM static ElectricChargeDensity() { - Info = ElectricChargeDensityInfo.CreateDefault(); + Info = ElectricChargeDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 553dafe511..0274531b57 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricConductanceInfo: QuantityInfo + private static class ElectricConductanceInfo { - /// - public ElectricConductanceInfo(string name, ElectricConductanceUnit baseUnit, IEnumerable> unitMappings, ElectricConductance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricConductance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricConductanceInfo(string name, ElectricConductanceUnit baseUnit, IEnumerable> unitMappings, ElectricConductance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricConductance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricConductance", typeof(ElectricConductance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricConductance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricConductanceInfo CreateDefault() - { - return new ElectricConductanceInfo(nameof(ElectricConductance), DefaultBaseUnit, GetDefaultMappings(), new ElectricConductance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricConductance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricConductanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricConductanceInfo(nameof(ElectricConductance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricConductance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricConductanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricConductance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricConductance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^3][L^-2][M^-1][I^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); /// /// The default base unit of ElectricConductance is Siemens. All conversions, as defined in the , go via this value. /// - public static ElectricConductanceUnit DefaultBaseUnit { get; } = ElectricConductanceUnit.Siemens; + private static ElectricConductanceUnit DefaultBaseUnit { get; } = ElectricConductanceUnit.Siemens; + + /// + /// The default resource manager for unit abbreviations of the ElectricConductance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricConductance", typeof(ElectricConductance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricConductance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricConductanceUnit.Gigamho, "Gigamho", "Gigamhos", BaseUnits.Undefined); yield return new (ElectricConductanceUnit.Gigasiemens, "Gigasiemens", "Gigasiemens", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Microgram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -140,7 +140,7 @@ public static IEnumerable> GetDefaultMap static ElectricConductance() { - Info = ElectricConductanceInfo.CreateDefault(); + Info = ElectricConductanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 5e8c9d7a0b..405a903bc2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricConductivityInfo: QuantityInfo + private static class ElectricConductivityInfo { - /// - public ElectricConductivityInfo(string name, ElectricConductivityUnit baseUnit, IEnumerable> unitMappings, ElectricConductivity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricConductivity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricConductivityInfo(string name, ElectricConductivityUnit baseUnit, IEnumerable> unitMappings, ElectricConductivity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricConductivity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricConductivity", typeof(ElectricConductivity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricConductivity quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricConductivityInfo CreateDefault() - { - return new ElectricConductivityInfo(nameof(ElectricConductivity), DefaultBaseUnit, GetDefaultMappings(), new ElectricConductivity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricConductivity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricConductivityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricConductivityInfo(nameof(ElectricConductivity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricConductivity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricConductivityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricConductivity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricConductivity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^3][L^-3][M^-1][I^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0); /// /// The default base unit of ElectricConductivity is SiemensPerMeter. All conversions, as defined in the , go via this value. /// - public static ElectricConductivityUnit DefaultBaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; + private static ElectricConductivityUnit DefaultBaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; + + /// + /// The default resource manager for unit abbreviations of the ElectricConductivity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricConductivity", typeof(ElectricConductivity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricConductivity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricConductivityUnit.MicrosiemensPerCentimeter, "MicrosiemensPerCentimeter", "MicrosiemensPerCentimeter", BaseUnits.Undefined); yield return new (ElectricConductivityUnit.MillisiemensPerCentimeter, "MillisiemensPerCentimeter", "MillisiemensPerCentimeter", BaseUnits.Undefined); @@ -130,7 +130,7 @@ public static IEnumerable> GetDefaultMa static ElectricConductivity() { - Info = ElectricConductivityInfo.CreateDefault(); + Info = ElectricConductivityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 02a8f156cd..4dc3fef13c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -72,59 +72,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricCurrentInfo: QuantityInfo + private static class ElectricCurrentInfo { - /// - public ElectricCurrentInfo(string name, ElectricCurrentUnit baseUnit, IEnumerable> unitMappings, ElectricCurrent zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricCurrent.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricCurrentInfo(string name, ElectricCurrentUnit baseUnit, IEnumerable> unitMappings, ElectricCurrent zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricCurrent.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricCurrent", typeof(ElectricCurrent).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricCurrent quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricCurrentInfo CreateDefault() - { - return new ElectricCurrentInfo(nameof(ElectricCurrent), DefaultBaseUnit, GetDefaultMappings(), new ElectricCurrent(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricCurrent quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricCurrentInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricCurrentInfo(nameof(ElectricCurrent), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricCurrent(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricCurrentInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricCurrent), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricCurrent(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 1, 0, 0, 0); /// /// The default base unit of ElectricCurrent is Ampere. All conversions, as defined in the , go via this value. /// - public static ElectricCurrentUnit DefaultBaseUnit { get; } = ElectricCurrentUnit.Ampere; + private static ElectricCurrentUnit DefaultBaseUnit { get; } = ElectricCurrentUnit.Ampere; + + /// + /// The default resource manager for unit abbreviations of the ElectricCurrent quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricCurrent", typeof(ElectricCurrent).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricCurrent. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricCurrentUnit.Ampere, "Ampere", "Amperes", new BaseUnits(current: ElectricCurrentUnit.Ampere)); yield return new (ElectricCurrentUnit.Centiampere, "Centiampere", "Centiamperes", new BaseUnits(current: ElectricCurrentUnit.Centiampere)); @@ -140,7 +140,7 @@ public static IEnumerable> GetDefaultMapping static ElectricCurrent() { - Info = ElectricCurrentInfo.CreateDefault(); + Info = ElectricCurrentInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 56b25ca786..1068b6c1ac 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricCurrentDensityInfo: QuantityInfo + private static class ElectricCurrentDensityInfo { - /// - public ElectricCurrentDensityInfo(string name, ElectricCurrentDensityUnit baseUnit, IEnumerable> unitMappings, ElectricCurrentDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricCurrentDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricCurrentDensityInfo(string name, ElectricCurrentDensityUnit baseUnit, IEnumerable> unitMappings, ElectricCurrentDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricCurrentDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricCurrentDensity", typeof(ElectricCurrentDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricCurrentDensity quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricCurrentDensityInfo CreateDefault() - { - return new ElectricCurrentDensityInfo(nameof(ElectricCurrentDensity), DefaultBaseUnit, GetDefaultMappings(), new ElectricCurrentDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricCurrentDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricCurrentDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricCurrentDensityInfo(nameof(ElectricCurrentDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricCurrentDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricCurrentDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricCurrentDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricCurrentDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-2][I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 1, 0, 0, 0); /// /// The default base unit of ElectricCurrentDensity is AmperePerSquareMeter. All conversions, as defined in the , go via this value. /// - public static ElectricCurrentDensityUnit DefaultBaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; + private static ElectricCurrentDensityUnit DefaultBaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the ElectricCurrentDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricCurrentDensity", typeof(ElectricCurrentDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricCurrentDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricCurrentDensityUnit.AmperePerSquareFoot, "AmperePerSquareFoot", "AmperesPerSquareFoot", new BaseUnits(length: LengthUnit.Foot, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricCurrentDensityUnit.AmperePerSquareInch, "AmperePerSquareInch", "AmperesPerSquareInch", new BaseUnits(length: LengthUnit.Inch, current: ElectricCurrentUnit.Ampere)); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefault static ElectricCurrentDensity() { - Info = ElectricCurrentDensityInfo.CreateDefault(); + Info = ElectricCurrentDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 048d513b36..78e56a1384 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricCurrentGradientInfo: QuantityInfo + private static class ElectricCurrentGradientInfo { - /// - public ElectricCurrentGradientInfo(string name, ElectricCurrentGradientUnit baseUnit, IEnumerable> unitMappings, ElectricCurrentGradient zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricCurrentGradient.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricCurrentGradientInfo(string name, ElectricCurrentGradientUnit baseUnit, IEnumerable> unitMappings, ElectricCurrentGradient zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricCurrentGradient.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricCurrentGradient", typeof(ElectricCurrentGradient).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricCurrentGradient quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricCurrentGradientInfo CreateDefault() - { - return new ElectricCurrentGradientInfo(nameof(ElectricCurrentGradient), DefaultBaseUnit, GetDefaultMappings(), new ElectricCurrentGradient(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricCurrentGradient quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricCurrentGradientInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricCurrentGradientInfo(nameof(ElectricCurrentGradient), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricCurrentGradient(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricCurrentGradientInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricCurrentGradient), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricCurrentGradient(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 1, 0, 0, 0); /// /// The default base unit of ElectricCurrentGradient is AmperePerSecond. All conversions, as defined in the , go via this value. /// - public static ElectricCurrentGradientUnit DefaultBaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; + private static ElectricCurrentGradientUnit DefaultBaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; + + /// + /// The default resource manager for unit abbreviations of the ElectricCurrentGradient quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricCurrentGradient", typeof(ElectricCurrentGradient).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricCurrentGradient. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricCurrentGradientUnit.AmperePerMicrosecond, "AmperePerMicrosecond", "AmperesPerMicrosecond", new BaseUnits(time: DurationUnit.Microsecond, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricCurrentGradientUnit.AmperePerMillisecond, "AmperePerMillisecond", "AmperesPerMillisecond", new BaseUnits(time: DurationUnit.Millisecond, current: ElectricCurrentUnit.Ampere)); @@ -131,7 +131,7 @@ public static IEnumerable> GetDefaul static ElectricCurrentGradient() { - Info = ElectricCurrentGradientInfo.CreateDefault(); + Info = ElectricCurrentGradientInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index bcb0fdcb06..5e44bfe478 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricFieldInfo: QuantityInfo + private static class ElectricFieldInfo { - /// - public ElectricFieldInfo(string name, ElectricFieldUnit baseUnit, IEnumerable> unitMappings, ElectricField zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricField.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricFieldInfo(string name, ElectricFieldUnit baseUnit, IEnumerable> unitMappings, ElectricField zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricField.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricField", typeof(ElectricField).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricField quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricFieldInfo CreateDefault() - { - return new ElectricFieldInfo(nameof(ElectricField), DefaultBaseUnit, GetDefaultMappings(), new ElectricField(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricField quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricFieldInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricFieldInfo(nameof(ElectricField), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricField(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricFieldInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricField), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricField(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L][M][I^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, -1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, -1, 0, 0, 0); /// /// The default base unit of ElectricField is VoltPerMeter. All conversions, as defined in the , go via this value. /// - public static ElectricFieldUnit DefaultBaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; + private static ElectricFieldUnit DefaultBaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; + + /// + /// The default resource manager for unit abbreviations of the ElectricField quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricField", typeof(ElectricField).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricField. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricFieldUnit.VoltPerMeter, "VoltPerMeter", "VoltsPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings( static ElectricField() { - Info = ElectricFieldInfo.CreateDefault(); + Info = ElectricFieldInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs index 51e187905e..678bc45282 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs @@ -66,59 +66,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricImpedanceInfo: QuantityInfo + private static class ElectricImpedanceInfo { - /// - public ElectricImpedanceInfo(string name, ElectricImpedanceUnit baseUnit, IEnumerable> unitMappings, ElectricImpedance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricImpedance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricImpedanceInfo(string name, ElectricImpedanceUnit baseUnit, IEnumerable> unitMappings, ElectricImpedance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricImpedance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricImpedance", typeof(ElectricImpedance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricImpedance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricImpedanceInfo CreateDefault() - { - return new ElectricImpedanceInfo(nameof(ElectricImpedance), DefaultBaseUnit, GetDefaultMappings(), new ElectricImpedance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricImpedance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricImpedanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricImpedanceInfo(nameof(ElectricImpedance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricImpedance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricImpedanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricImpedance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricImpedance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M][I^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); /// /// The default base unit of ElectricImpedance is Ohm. All conversions, as defined in the , go via this value. /// - public static ElectricImpedanceUnit DefaultBaseUnit { get; } = ElectricImpedanceUnit.Ohm; + private static ElectricImpedanceUnit DefaultBaseUnit { get; } = ElectricImpedanceUnit.Ohm; + + /// + /// The default resource manager for unit abbreviations of the ElectricImpedance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricImpedance", typeof(ElectricImpedance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricImpedance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricImpedanceUnit.Gigaohm, "Gigaohm", "Gigaohms", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Millisecond, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricImpedanceUnit.Kiloohm, "Kiloohm", "Kiloohms", BaseUnits.Undefined); @@ -133,7 +133,7 @@ public static IEnumerable> GetDefaultMappi static ElectricImpedance() { - Info = ElectricImpedanceInfo.CreateDefault(); + Info = ElectricImpedanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 223119f6e9..d0fb4aa0bd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricInductanceInfo: QuantityInfo + private static class ElectricInductanceInfo { - /// - public ElectricInductanceInfo(string name, ElectricInductanceUnit baseUnit, IEnumerable> unitMappings, ElectricInductance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricInductance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricInductanceInfo(string name, ElectricInductanceUnit baseUnit, IEnumerable> unitMappings, ElectricInductance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricInductance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricInductance", typeof(ElectricInductance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricInductance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricInductanceInfo CreateDefault() - { - return new ElectricInductanceInfo(nameof(ElectricInductance), DefaultBaseUnit, GetDefaultMappings(), new ElectricInductance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricInductance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricInductanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricInductanceInfo(nameof(ElectricInductance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricInductance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricInductanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricInductance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricInductance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M][I^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, -2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, -2, 0, 0, 0); /// /// The default base unit of ElectricInductance is Henry. All conversions, as defined in the , go via this value. /// - public static ElectricInductanceUnit DefaultBaseUnit { get; } = ElectricInductanceUnit.Henry; + private static ElectricInductanceUnit DefaultBaseUnit { get; } = ElectricInductanceUnit.Henry; + + /// + /// The default resource manager for unit abbreviations of the ElectricInductance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricInductance", typeof(ElectricInductance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricInductance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricInductanceUnit.Henry, "Henry", "Henries", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricInductanceUnit.Microhenry, "Microhenry", "Microhenries", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Milligram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -129,7 +129,7 @@ public static IEnumerable> GetDefaultMapp static ElectricInductance() { - Info = ElectricInductanceInfo.CreateDefault(); + Info = ElectricInductanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 55145ee327..b4e2de63f3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -71,59 +71,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricPotentialInfo: QuantityInfo + private static class ElectricPotentialInfo { - /// - public ElectricPotentialInfo(string name, ElectricPotentialUnit baseUnit, IEnumerable> unitMappings, ElectricPotential zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricPotential.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricPotentialInfo(string name, ElectricPotentialUnit baseUnit, IEnumerable> unitMappings, ElectricPotential zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricPotential.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricPotential", typeof(ElectricPotential).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricPotential quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricPotentialInfo CreateDefault() - { - return new ElectricPotentialInfo(nameof(ElectricPotential), DefaultBaseUnit, GetDefaultMappings(), new ElectricPotential(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricPotential quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricPotentialInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricPotentialInfo(nameof(ElectricPotential), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricPotential(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricPotentialInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricPotential), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricPotential(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M][I^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -1, 0, 0, 0); /// /// The default base unit of ElectricPotential is Volt. All conversions, as defined in the , go via this value. /// - public static ElectricPotentialUnit DefaultBaseUnit { get; } = ElectricPotentialUnit.Volt; + private static ElectricPotentialUnit DefaultBaseUnit { get; } = ElectricPotentialUnit.Volt; + + /// + /// The default resource manager for unit abbreviations of the ElectricPotential quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricPotential", typeof(ElectricPotential).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricPotential. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricPotentialUnit.Kilovolt, "Kilovolt", "Kilovolts", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Milliampere)); yield return new (ElectricPotentialUnit.Megavolt, "Megavolt", "Megavolts", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Microampere)); @@ -136,7 +136,7 @@ public static IEnumerable> GetDefaultMappi static ElectricPotential() { - Info = ElectricPotentialInfo.CreateDefault(); + Info = ElectricPotentialInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index a0d97d90db..7d44f362cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricPotentialChangeRateInfo: QuantityInfo + private static class ElectricPotentialChangeRateInfo { - /// - public ElectricPotentialChangeRateInfo(string name, ElectricPotentialChangeRateUnit baseUnit, IEnumerable> unitMappings, ElectricPotentialChangeRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricPotentialChangeRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricPotentialChangeRateInfo(string name, ElectricPotentialChangeRateUnit baseUnit, IEnumerable> unitMappings, ElectricPotentialChangeRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricPotentialChangeRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricPotentialChangeRate", typeof(ElectricPotentialChangeRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricPotentialChangeRate quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricPotentialChangeRateInfo CreateDefault() - { - return new ElectricPotentialChangeRateInfo(nameof(ElectricPotentialChangeRate), DefaultBaseUnit, GetDefaultMappings(), new ElectricPotentialChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricPotentialChangeRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricPotentialChangeRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricPotentialChangeRateInfo(nameof(ElectricPotentialChangeRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricPotentialChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricPotentialChangeRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricPotentialChangeRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricPotentialChangeRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-4][L^2][M][I^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -4, -1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -4, -1, 0, 0, 0); /// /// The default base unit of ElectricPotentialChangeRate is VoltPerSecond. All conversions, as defined in the , go via this value. /// - public static ElectricPotentialChangeRateUnit DefaultBaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; + private static ElectricPotentialChangeRateUnit DefaultBaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; + + /// + /// The default resource manager for unit abbreviations of the ElectricPotentialChangeRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricPotentialChangeRate", typeof(ElectricPotentialChangeRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricPotentialChangeRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricPotentialChangeRateUnit.KilovoltPerHour, "KilovoltPerHour", "KilovoltsPerHour", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Hour, current: ElectricCurrentUnit.Milliampere)); yield return new (ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, "KilovoltPerMicrosecond", "KilovoltsPerMicrosecond", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Microsecond, current: ElectricCurrentUnit.Milliampere)); @@ -141,7 +141,7 @@ public static IEnumerable> GetDe static ElectricPotentialChangeRate() { - Info = ElectricPotentialChangeRateInfo.CreateDefault(); + Info = ElectricPotentialChangeRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs index 3146210299..bc072be98c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricReactanceInfo: QuantityInfo + private static class ElectricReactanceInfo { - /// - public ElectricReactanceInfo(string name, ElectricReactanceUnit baseUnit, IEnumerable> unitMappings, ElectricReactance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricReactance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricReactanceInfo(string name, ElectricReactanceUnit baseUnit, IEnumerable> unitMappings, ElectricReactance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricReactance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricReactance", typeof(ElectricReactance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricReactance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricReactanceInfo CreateDefault() - { - return new ElectricReactanceInfo(nameof(ElectricReactance), DefaultBaseUnit, GetDefaultMappings(), new ElectricReactance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricReactance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricReactanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricReactanceInfo(nameof(ElectricReactance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricReactance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricReactanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricReactance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricReactance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M][I^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); /// /// The default base unit of ElectricReactance is Ohm. All conversions, as defined in the , go via this value. /// - public static ElectricReactanceUnit DefaultBaseUnit { get; } = ElectricReactanceUnit.Ohm; + private static ElectricReactanceUnit DefaultBaseUnit { get; } = ElectricReactanceUnit.Ohm; + + /// + /// The default resource manager for unit abbreviations of the ElectricReactance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricReactance", typeof(ElectricReactance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricReactance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricReactanceUnit.Gigaohm, "Gigaohm", "Gigaohms", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Millisecond, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricReactanceUnit.Kiloohm, "Kiloohm", "Kiloohms", BaseUnits.Undefined); @@ -132,7 +132,7 @@ public static IEnumerable> GetDefaultMappi static ElectricReactance() { - Info = ElectricReactanceInfo.CreateDefault(); + Info = ElectricReactanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs index 17585bb6ec..0d152234f8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricReactiveEnergyInfo: QuantityInfo + private static class ElectricReactiveEnergyInfo { - /// - public ElectricReactiveEnergyInfo(string name, ElectricReactiveEnergyUnit baseUnit, IEnumerable> unitMappings, ElectricReactiveEnergy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricReactiveEnergy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricReactiveEnergyInfo(string name, ElectricReactiveEnergyUnit baseUnit, IEnumerable> unitMappings, ElectricReactiveEnergy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricReactiveEnergy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricReactiveEnergy", typeof(ElectricReactiveEnergy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricReactiveEnergy quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricReactiveEnergyInfo CreateDefault() - { - return new ElectricReactiveEnergyInfo(nameof(ElectricReactiveEnergy), DefaultBaseUnit, GetDefaultMappings(), new ElectricReactiveEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricReactiveEnergy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricReactiveEnergyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricReactiveEnergyInfo(nameof(ElectricReactiveEnergy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricReactiveEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricReactiveEnergyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricReactiveEnergy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricReactiveEnergy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); /// /// The default base unit of ElectricReactiveEnergy is VoltampereReactiveHour. All conversions, as defined in the , go via this value. /// - public static ElectricReactiveEnergyUnit DefaultBaseUnit { get; } = ElectricReactiveEnergyUnit.VoltampereReactiveHour; + private static ElectricReactiveEnergyUnit DefaultBaseUnit { get; } = ElectricReactiveEnergyUnit.VoltampereReactiveHour; + + /// + /// The default resource manager for unit abbreviations of the ElectricReactiveEnergy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricReactiveEnergy", typeof(ElectricReactiveEnergy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricReactiveEnergy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricReactiveEnergyUnit.KilovoltampereReactiveHour, "KilovoltampereReactiveHour", "KilovoltampereReactiveHours", BaseUnits.Undefined); yield return new (ElectricReactiveEnergyUnit.MegavoltampereReactiveHour, "MegavoltampereReactiveHour", "MegavoltampereReactiveHours", BaseUnits.Undefined); @@ -124,7 +124,7 @@ public static IEnumerable> GetDefault static ElectricReactiveEnergy() { - Info = ElectricReactiveEnergyInfo.CreateDefault(); + Info = ElectricReactiveEnergyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs index e0d759a03f..089057b0a3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricReactivePowerInfo: QuantityInfo + private static class ElectricReactivePowerInfo { - /// - public ElectricReactivePowerInfo(string name, ElectricReactivePowerUnit baseUnit, IEnumerable> unitMappings, ElectricReactivePower zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricReactivePower.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricReactivePowerInfo(string name, ElectricReactivePowerUnit baseUnit, IEnumerable> unitMappings, ElectricReactivePower zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricReactivePower.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricReactivePower", typeof(ElectricReactivePower).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricReactivePower quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricReactivePowerInfo CreateDefault() - { - return new ElectricReactivePowerInfo(nameof(ElectricReactivePower), DefaultBaseUnit, GetDefaultMappings(), new ElectricReactivePower(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricReactivePower quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricReactivePowerInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricReactivePowerInfo(nameof(ElectricReactivePower), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricReactivePower(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricReactivePowerInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricReactivePower), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricReactivePower(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); /// /// The default base unit of ElectricReactivePower is VoltampereReactive. All conversions, as defined in the , go via this value. /// - public static ElectricReactivePowerUnit DefaultBaseUnit { get; } = ElectricReactivePowerUnit.VoltampereReactive; + private static ElectricReactivePowerUnit DefaultBaseUnit { get; } = ElectricReactivePowerUnit.VoltampereReactive; + + /// + /// The default resource manager for unit abbreviations of the ElectricReactivePower quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricReactivePower", typeof(ElectricReactivePower).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricReactivePower. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricReactivePowerUnit.GigavoltampereReactive, "GigavoltampereReactive", "GigavoltamperesReactive", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Millisecond)); yield return new (ElectricReactivePowerUnit.KilovoltampereReactive, "KilovoltampereReactive", "KilovoltamperesReactive", BaseUnits.Undefined); @@ -128,7 +128,7 @@ public static IEnumerable> GetDefaultM static ElectricReactivePower() { - Info = ElectricReactivePowerInfo.CreateDefault(); + Info = ElectricReactivePowerInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 5c6c3b59ce..efaad9dd47 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -68,59 +68,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricResistanceInfo: QuantityInfo + private static class ElectricResistanceInfo { - /// - public ElectricResistanceInfo(string name, ElectricResistanceUnit baseUnit, IEnumerable> unitMappings, ElectricResistance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricResistance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricResistanceInfo(string name, ElectricResistanceUnit baseUnit, IEnumerable> unitMappings, ElectricResistance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricResistance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricResistance", typeof(ElectricResistance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricResistance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricResistanceInfo CreateDefault() - { - return new ElectricResistanceInfo(nameof(ElectricResistance), DefaultBaseUnit, GetDefaultMappings(), new ElectricResistance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricResistance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricResistanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricResistanceInfo(nameof(ElectricResistance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricResistance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricResistanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricResistance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricResistance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M][I^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); /// /// The default base unit of ElectricResistance is Ohm. All conversions, as defined in the , go via this value. /// - public static ElectricResistanceUnit DefaultBaseUnit { get; } = ElectricResistanceUnit.Ohm; + private static ElectricResistanceUnit DefaultBaseUnit { get; } = ElectricResistanceUnit.Ohm; + + /// + /// The default resource manager for unit abbreviations of the ElectricResistance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricResistance", typeof(ElectricResistance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricResistance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricResistanceUnit.Gigaohm, "Gigaohm", "Gigaohms", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Millisecond, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricResistanceUnit.Kiloohm, "Kiloohm", "Kiloohms", BaseUnits.Undefined); @@ -135,7 +135,7 @@ public static IEnumerable> GetDefaultMapp static ElectricResistance() { - Info = ElectricResistanceInfo.CreateDefault(); + Info = ElectricResistanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 098ce09da4..e78ba42524 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricResistivityInfo: QuantityInfo + private static class ElectricResistivityInfo { - /// - public ElectricResistivityInfo(string name, ElectricResistivityUnit baseUnit, IEnumerable> unitMappings, ElectricResistivity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricResistivity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricResistivityInfo(string name, ElectricResistivityUnit baseUnit, IEnumerable> unitMappings, ElectricResistivity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricResistivity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricResistivity", typeof(ElectricResistivity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricResistivity quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricResistivityInfo CreateDefault() - { - return new ElectricResistivityInfo(nameof(ElectricResistivity), DefaultBaseUnit, GetDefaultMappings(), new ElectricResistivity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricResistivity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricResistivityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricResistivityInfo(nameof(ElectricResistivity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricResistivity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricResistivityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricResistivity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricResistivity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^3][M][I^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, 1, -3, -2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, 1, -3, -2, 0, 0, 0); /// /// The default base unit of ElectricResistivity is OhmMeter. All conversions, as defined in the , go via this value. /// - public static ElectricResistivityUnit DefaultBaseUnit { get; } = ElectricResistivityUnit.OhmMeter; + private static ElectricResistivityUnit DefaultBaseUnit { get; } = ElectricResistivityUnit.OhmMeter; + + /// + /// The default resource manager for unit abbreviations of the ElectricResistivity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricResistivity", typeof(ElectricResistivity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricResistivity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricResistivityUnit.KiloohmCentimeter, "KiloohmCentimeter", "KiloohmsCentimeter", BaseUnits.Undefined); yield return new (ElectricResistivityUnit.KiloohmMeter, "KiloohmMeter", "KiloohmMeters", new BaseUnits(length: LengthUnit.Decameter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -138,7 +138,7 @@ public static IEnumerable> GetDefaultMap static ElectricResistivity() { - Info = ElectricResistivityInfo.CreateDefault(); + Info = ElectricResistivityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 1fb26fa9e7..71ad1071ee 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricSurfaceChargeDensityInfo: QuantityInfo + private static class ElectricSurfaceChargeDensityInfo { - /// - public ElectricSurfaceChargeDensityInfo(string name, ElectricSurfaceChargeDensityUnit baseUnit, IEnumerable> unitMappings, ElectricSurfaceChargeDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricSurfaceChargeDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricSurfaceChargeDensityInfo(string name, ElectricSurfaceChargeDensityUnit baseUnit, IEnumerable> unitMappings, ElectricSurfaceChargeDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricSurfaceChargeDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricSurfaceChargeDensity", typeof(ElectricSurfaceChargeDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricSurfaceChargeDensity quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricSurfaceChargeDensityInfo CreateDefault() - { - return new ElectricSurfaceChargeDensityInfo(nameof(ElectricSurfaceChargeDensity), DefaultBaseUnit, GetDefaultMappings(), new ElectricSurfaceChargeDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricSurfaceChargeDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricSurfaceChargeDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricSurfaceChargeDensityInfo(nameof(ElectricSurfaceChargeDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricSurfaceChargeDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricSurfaceChargeDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricSurfaceChargeDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricSurfaceChargeDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T][L^-2][I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 1, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 1, 1, 0, 0, 0); /// /// The default base unit of ElectricSurfaceChargeDensity is CoulombPerSquareMeter. All conversions, as defined in the , go via this value. /// - public static ElectricSurfaceChargeDensityUnit DefaultBaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; + private static ElectricSurfaceChargeDensityUnit DefaultBaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the ElectricSurfaceChargeDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricSurfaceChargeDensity", typeof(ElectricSurfaceChargeDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricSurfaceChargeDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, "CoulombPerSquareCentimeter", "CoulombsPerSquareCentimeter", new BaseUnits(length: LengthUnit.Centimeter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); yield return new (ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, "CoulombPerSquareInch", "CoulombsPerSquareInch", new BaseUnits(length: LengthUnit.Inch, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -127,7 +127,7 @@ public static IEnumerable> GetD static ElectricSurfaceChargeDensity() { - Info = ElectricSurfaceChargeDensityInfo.CreateDefault(); + Info = ElectricSurfaceChargeDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs index de658fefac..797c91e7ac 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ElectricSusceptanceInfo: QuantityInfo + private static class ElectricSusceptanceInfo { - /// - public ElectricSusceptanceInfo(string name, ElectricSusceptanceUnit baseUnit, IEnumerable> unitMappings, ElectricSusceptance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ElectricSusceptance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ElectricSusceptanceInfo(string name, ElectricSusceptanceUnit baseUnit, IEnumerable> unitMappings, ElectricSusceptance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ElectricSusceptance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ElectricSusceptance", typeof(ElectricSusceptance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ElectricSusceptance quantity. - /// - /// A new instance of the class with the default settings. - public static ElectricSusceptanceInfo CreateDefault() - { - return new ElectricSusceptanceInfo(nameof(ElectricSusceptance), DefaultBaseUnit, GetDefaultMappings(), new ElectricSusceptance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ElectricSusceptance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ElectricSusceptanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ElectricSusceptanceInfo(nameof(ElectricSusceptance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ElectricSusceptance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ElectricSusceptanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ElectricSusceptance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ElectricSusceptance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^3][L^-2][M^-1][I^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); /// /// The default base unit of ElectricSusceptance is Siemens. All conversions, as defined in the , go via this value. /// - public static ElectricSusceptanceUnit DefaultBaseUnit { get; } = ElectricSusceptanceUnit.Siemens; + private static ElectricSusceptanceUnit DefaultBaseUnit { get; } = ElectricSusceptanceUnit.Siemens; + + /// + /// The default resource manager for unit abbreviations of the ElectricSusceptance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ElectricSusceptance", typeof(ElectricSusceptance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ElectricSusceptance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ElectricSusceptanceUnit.Gigamho, "Gigamho", "Gigamhos", BaseUnits.Undefined); yield return new (ElectricSusceptanceUnit.Gigasiemens, "Gigasiemens", "Gigasiemens", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Microgram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); @@ -140,7 +140,7 @@ public static IEnumerable> GetDefaultMap static ElectricSusceptance() { - Info = ElectricSusceptanceInfo.CreateDefault(); + Info = ElectricSusceptanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 31dc21b211..1e95b21069 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -77,59 +77,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class EnergyInfo: QuantityInfo + private static class EnergyInfo { - /// - public EnergyInfo(string name, EnergyUnit baseUnit, IEnumerable> unitMappings, Energy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Energy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public EnergyInfo(string name, EnergyUnit baseUnit, IEnumerable> unitMappings, Energy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Energy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Energy", typeof(Energy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Energy quantity. - /// - /// A new instance of the class with the default settings. - public static EnergyInfo CreateDefault() - { - return new EnergyInfo(nameof(Energy), DefaultBaseUnit, GetDefaultMappings(), new Energy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Energy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static EnergyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new EnergyInfo(nameof(Energy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Energy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = EnergyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Energy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Energy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); /// /// The default base unit of Energy is Joule. All conversions, as defined in the , go via this value. /// - public static EnergyUnit DefaultBaseUnit { get; } = EnergyUnit.Joule; + private static EnergyUnit DefaultBaseUnit { get; } = EnergyUnit.Joule; + + /// + /// The default resource manager for unit abbreviations of the Energy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Energy", typeof(Energy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Energy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (EnergyUnit.BritishThermalUnit, "BritishThermalUnit", "BritishThermalUnits", BaseUnits.Undefined); yield return new (EnergyUnit.Calorie, "Calorie", "Calories", BaseUnits.Undefined); @@ -176,7 +176,7 @@ public static IEnumerable> GetDefaultMappings() static Energy() { - Info = EnergyInfo.CreateDefault(); + Info = EnergyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 9d8c96a8a9..9b7ce979e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class EnergyDensityInfo: QuantityInfo + private static class EnergyDensityInfo { - /// - public EnergyDensityInfo(string name, EnergyDensityUnit baseUnit, IEnumerable> unitMappings, EnergyDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, EnergyDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public EnergyDensityInfo(string name, EnergyDensityUnit baseUnit, IEnumerable> unitMappings, EnergyDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, EnergyDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.EnergyDensity", typeof(EnergyDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the EnergyDensity quantity. - /// - /// A new instance of the class with the default settings. - public static EnergyDensityInfo CreateDefault() - { - return new EnergyDensityInfo(nameof(EnergyDensity), DefaultBaseUnit, GetDefaultMappings(), new EnergyDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the EnergyDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static EnergyDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new EnergyDensityInfo(nameof(EnergyDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new EnergyDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = EnergyDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(EnergyDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new EnergyDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); /// /// The default base unit of EnergyDensity is JoulePerCubicMeter. All conversions, as defined in the , go via this value. /// - public static EnergyDensityUnit DefaultBaseUnit { get; } = EnergyDensityUnit.JoulePerCubicMeter; + private static EnergyDensityUnit DefaultBaseUnit { get; } = EnergyDensityUnit.JoulePerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the EnergyDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.EnergyDensity", typeof(EnergyDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for EnergyDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (EnergyDensityUnit.GigajoulePerCubicMeter, "GigajoulePerCubicMeter", "GigajoulesPerCubicMeter", new BaseUnits(length: LengthUnit.Nanometer, mass: MassUnit.Kilogram, time: DurationUnit.Second)); yield return new (EnergyDensityUnit.GigawattHourPerCubicMeter, "GigawattHourPerCubicMeter", "GigawattHoursPerCubicMeter", BaseUnits.Undefined); @@ -136,7 +136,7 @@ public static IEnumerable> GetDefaultMappings( static EnergyDensity() { - Info = EnergyDensityInfo.CreateDefault(); + Info = EnergyDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 51fe1580e9..5ae5cf52a8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -67,59 +67,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class EntropyInfo: QuantityInfo + private static class EntropyInfo { - /// - public EntropyInfo(string name, EntropyUnit baseUnit, IEnumerable> unitMappings, Entropy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Entropy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public EntropyInfo(string name, EntropyUnit baseUnit, IEnumerable> unitMappings, Entropy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Entropy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Entropy", typeof(Entropy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Entropy quantity. - /// - /// A new instance of the class with the default settings. - public static EntropyInfo CreateDefault() - { - return new EntropyInfo(nameof(Entropy), DefaultBaseUnit, GetDefaultMappings(), new Entropy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Entropy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static EntropyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new EntropyInfo(nameof(Entropy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Entropy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = EntropyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Entropy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Entropy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M][Θ^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, -1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, -1, 0, 0); /// /// The default base unit of Entropy is JoulePerKelvin. All conversions, as defined in the , go via this value. /// - public static EntropyUnit DefaultBaseUnit { get; } = EntropyUnit.JoulePerKelvin; + private static EntropyUnit DefaultBaseUnit { get; } = EntropyUnit.JoulePerKelvin; + + /// + /// The default resource manager for unit abbreviations of the Entropy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Entropy", typeof(Entropy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Entropy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (EntropyUnit.CaloriePerKelvin, "CaloriePerKelvin", "CaloriesPerKelvin", BaseUnits.Undefined); yield return new (EntropyUnit.JoulePerDegreeCelsius, "JoulePerDegreeCelsius", "JoulesPerDegreeCelsius", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, temperature: TemperatureUnit.DegreeCelsius)); @@ -133,7 +133,7 @@ public static IEnumerable> GetDefaultMappings() static Entropy() { - Info = EntropyInfo.CreateDefault(); + Info = EntropyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs index d4b04628e1..8b7c88b77e 100644 --- a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class FluidResistanceInfo: QuantityInfo + private static class FluidResistanceInfo { - /// - public FluidResistanceInfo(string name, FluidResistanceUnit baseUnit, IEnumerable> unitMappings, FluidResistance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, FluidResistance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public FluidResistanceInfo(string name, FluidResistanceUnit baseUnit, IEnumerable> unitMappings, FluidResistance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, FluidResistance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.FluidResistance", typeof(FluidResistance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the FluidResistance quantity. - /// - /// A new instance of the class with the default settings. - public static FluidResistanceInfo CreateDefault() - { - return new FluidResistanceInfo(nameof(FluidResistance), DefaultBaseUnit, GetDefaultMappings(), new FluidResistance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the FluidResistance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static FluidResistanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new FluidResistanceInfo(nameof(FluidResistance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new FluidResistance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = FluidResistanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(FluidResistance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new FluidResistance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L^-4][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-4, 1, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-4, 1, -1, 0, 0, 0, 0); /// /// The default base unit of FluidResistance is PascalSecondPerCubicMeter. All conversions, as defined in the , go via this value. /// - public static FluidResistanceUnit DefaultBaseUnit { get; } = FluidResistanceUnit.PascalSecondPerCubicMeter; + private static FluidResistanceUnit DefaultBaseUnit { get; } = FluidResistanceUnit.PascalSecondPerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the FluidResistance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.FluidResistance", typeof(FluidResistance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for FluidResistance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, "DyneSecondPerCentimeterToTheFifth", "DyneSecondsPerCentimeterToTheFifth", BaseUnits.Undefined); yield return new (FluidResistanceUnit.MegapascalSecondPerCubicMeter, "MegapascalSecondPerCubicMeter", "MegapascalSecondsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Microsecond)); @@ -143,7 +143,7 @@ public static IEnumerable> GetDefaultMapping static FluidResistance() { - Info = FluidResistanceInfo.CreateDefault(); + Info = FluidResistanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 5c1e1275f3..9c493c4c2c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -76,59 +76,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ForceInfo: QuantityInfo + private static class ForceInfo { - /// - public ForceInfo(string name, ForceUnit baseUnit, IEnumerable> unitMappings, Force zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Force.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ForceInfo(string name, ForceUnit baseUnit, IEnumerable> unitMappings, Force zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Force.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Force", typeof(Force).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Force quantity. - /// - /// A new instance of the class with the default settings. - public static ForceInfo CreateDefault() - { - return new ForceInfo(nameof(Force), DefaultBaseUnit, GetDefaultMappings(), new Force(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Force quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ForceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ForceInfo(nameof(Force), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Force(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ForceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Force), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Force(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); /// /// The default base unit of Force is Newton. All conversions, as defined in the , go via this value. /// - public static ForceUnit DefaultBaseUnit { get; } = ForceUnit.Newton; + private static ForceUnit DefaultBaseUnit { get; } = ForceUnit.Newton; + + /// + /// The default resource manager for unit abbreviations of the Force quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Force", typeof(Force).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Force. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ForceUnit.Decanewton, "Decanewton", "Decanewtons", new BaseUnits(length: LengthUnit.Decameter, mass: MassUnit.Kilogram, time: DurationUnit.Second)); yield return new (ForceUnit.Dyn, "Dyn", "Dyne", new BaseUnits(length: LengthUnit.Centimeter, mass: MassUnit.Gram, time: DurationUnit.Second)); @@ -150,7 +150,7 @@ public static IEnumerable> GetDefaultMappings() static Force() { - Info = ForceInfo.CreateDefault(); + Info = ForceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 8333dec2b1..f0a8484c64 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ForceChangeRateInfo: QuantityInfo + private static class ForceChangeRateInfo { - /// - public ForceChangeRateInfo(string name, ForceChangeRateUnit baseUnit, IEnumerable> unitMappings, ForceChangeRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ForceChangeRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ForceChangeRateInfo(string name, ForceChangeRateUnit baseUnit, IEnumerable> unitMappings, ForceChangeRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ForceChangeRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ForceChangeRate", typeof(ForceChangeRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ForceChangeRate quantity. - /// - /// A new instance of the class with the default settings. - public static ForceChangeRateInfo CreateDefault() - { - return new ForceChangeRateInfo(nameof(ForceChangeRate), DefaultBaseUnit, GetDefaultMappings(), new ForceChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ForceChangeRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ForceChangeRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ForceChangeRateInfo(nameof(ForceChangeRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ForceChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ForceChangeRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ForceChangeRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ForceChangeRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); /// /// The default base unit of ForceChangeRate is NewtonPerSecond. All conversions, as defined in the , go via this value. /// - public static ForceChangeRateUnit DefaultBaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; + private static ForceChangeRateUnit DefaultBaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; + + /// + /// The default resource manager for unit abbreviations of the ForceChangeRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ForceChangeRate", typeof(ForceChangeRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ForceChangeRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ForceChangeRateUnit.CentinewtonPerSecond, "CentinewtonPerSecond", "CentinewtonsPerSecond", new BaseUnits(length: LengthUnit.Centimeter, mass: MassUnit.Kilogram, time: DurationUnit.Second)); yield return new (ForceChangeRateUnit.DecanewtonPerMinute, "DecanewtonPerMinute", "DecanewtonsPerMinute", BaseUnits.Undefined); @@ -139,7 +139,7 @@ public static IEnumerable> GetDefaultMapping static ForceChangeRate() { - Info = ForceChangeRateInfo.CreateDefault(); + Info = ForceChangeRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 15df47e0ed..7cfe819503 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -73,59 +73,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ForcePerLengthInfo: QuantityInfo + private static class ForcePerLengthInfo { - /// - public ForcePerLengthInfo(string name, ForcePerLengthUnit baseUnit, IEnumerable> unitMappings, ForcePerLength zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ForcePerLength.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ForcePerLengthInfo(string name, ForcePerLengthUnit baseUnit, IEnumerable> unitMappings, ForcePerLength zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ForcePerLength.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ForcePerLength", typeof(ForcePerLength).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ForcePerLength quantity. - /// - /// A new instance of the class with the default settings. - public static ForcePerLengthInfo CreateDefault() - { - return new ForcePerLengthInfo(nameof(ForcePerLength), DefaultBaseUnit, GetDefaultMappings(), new ForcePerLength(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ForcePerLength quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ForcePerLengthInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ForcePerLengthInfo(nameof(ForcePerLength), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ForcePerLength(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ForcePerLengthInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ForcePerLength), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ForcePerLength(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); /// /// The default base unit of ForcePerLength is NewtonPerMeter. All conversions, as defined in the , go via this value. /// - public static ForcePerLengthUnit DefaultBaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; + private static ForcePerLengthUnit DefaultBaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; + + /// + /// The default resource manager for unit abbreviations of the ForcePerLength quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ForcePerLength", typeof(ForcePerLength).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ForcePerLength. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ForcePerLengthUnit.CentinewtonPerCentimeter, "CentinewtonPerCentimeter", "CentinewtonsPerCentimeter", BaseUnits.Undefined); yield return new (ForcePerLengthUnit.CentinewtonPerMeter, "CentinewtonPerMeter", "CentinewtonsPerMeter", new BaseUnits(mass: MassUnit.Decagram, time: DurationUnit.Second)); @@ -170,7 +170,7 @@ public static IEnumerable> GetDefaultMappings static ForcePerLength() { - Info = ForcePerLengthInfo.CreateDefault(); + Info = ForcePerLengthInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index b6d253e914..8c6fd846ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class FrequencyInfo: QuantityInfo + private static class FrequencyInfo { - /// - public FrequencyInfo(string name, FrequencyUnit baseUnit, IEnumerable> unitMappings, Frequency zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Frequency.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public FrequencyInfo(string name, FrequencyUnit baseUnit, IEnumerable> unitMappings, Frequency zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Frequency.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Frequency", typeof(Frequency).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Frequency quantity. - /// - /// A new instance of the class with the default settings. - public static FrequencyInfo CreateDefault() - { - return new FrequencyInfo(nameof(Frequency), DefaultBaseUnit, GetDefaultMappings(), new Frequency(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Frequency quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static FrequencyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new FrequencyInfo(nameof(Frequency), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Frequency(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = FrequencyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Frequency), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Frequency(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); /// /// The default base unit of Frequency is Hertz. All conversions, as defined in the , go via this value. /// - public static FrequencyUnit DefaultBaseUnit { get; } = FrequencyUnit.Hertz; + private static FrequencyUnit DefaultBaseUnit { get; } = FrequencyUnit.Hertz; + + /// + /// The default resource manager for unit abbreviations of the Frequency quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Frequency", typeof(Frequency).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Frequency. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (FrequencyUnit.BeatPerMinute, "BeatPerMinute", "BeatsPerMinute", new BaseUnits(time: DurationUnit.Minute)); yield return new (FrequencyUnit.CyclePerHour, "CyclePerHour", "CyclesPerHour", new BaseUnits(time: DurationUnit.Hour)); @@ -136,7 +136,7 @@ public static IEnumerable> GetDefaultMappings() static Frequency() { - Info = FrequencyInfo.CreateDefault(); + Info = FrequencyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 5336572867..510e7a5777 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class FuelEfficiencyInfo: QuantityInfo + private static class FuelEfficiencyInfo { - /// - public FuelEfficiencyInfo(string name, FuelEfficiencyUnit baseUnit, IEnumerable> unitMappings, FuelEfficiency zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, FuelEfficiency.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public FuelEfficiencyInfo(string name, FuelEfficiencyUnit baseUnit, IEnumerable> unitMappings, FuelEfficiency zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, FuelEfficiency.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.FuelEfficiency", typeof(FuelEfficiency).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the FuelEfficiency quantity. - /// - /// A new instance of the class with the default settings. - public static FuelEfficiencyInfo CreateDefault() - { - return new FuelEfficiencyInfo(nameof(FuelEfficiency), DefaultBaseUnit, GetDefaultMappings(), new FuelEfficiency(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the FuelEfficiency quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static FuelEfficiencyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new FuelEfficiencyInfo(nameof(FuelEfficiency), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new FuelEfficiency(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = FuelEfficiencyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(FuelEfficiency), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new FuelEfficiency(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 0); /// /// The default base unit of FuelEfficiency is KilometerPerLiter. All conversions, as defined in the , go via this value. /// - public static FuelEfficiencyUnit DefaultBaseUnit { get; } = FuelEfficiencyUnit.KilometerPerLiter; + private static FuelEfficiencyUnit DefaultBaseUnit { get; } = FuelEfficiencyUnit.KilometerPerLiter; + + /// + /// The default resource manager for unit abbreviations of the FuelEfficiency quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.FuelEfficiency", typeof(FuelEfficiency).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for FuelEfficiency. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (FuelEfficiencyUnit.KilometerPerLiter, "KilometerPerLiter", "KilometersPerLiter", BaseUnits.Undefined); yield return new (FuelEfficiencyUnit.LiterPer100Kilometers, "LiterPer100Kilometers", "LitersPer100Kilometers", BaseUnits.Undefined); @@ -128,7 +128,7 @@ public static IEnumerable> GetDefaultMappings static FuelEfficiency() { - Info = FuelEfficiencyInfo.CreateDefault(); + Info = FuelEfficiencyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 10effb59b7..47a8d7104a 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class HeatFluxInfo: QuantityInfo + private static class HeatFluxInfo { - /// - public HeatFluxInfo(string name, HeatFluxUnit baseUnit, IEnumerable> unitMappings, HeatFlux zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, HeatFlux.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public HeatFluxInfo(string name, HeatFluxUnit baseUnit, IEnumerable> unitMappings, HeatFlux zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, HeatFlux.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.HeatFlux", typeof(HeatFlux).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the HeatFlux quantity. - /// - /// A new instance of the class with the default settings. - public static HeatFluxInfo CreateDefault() - { - return new HeatFluxInfo(nameof(HeatFlux), DefaultBaseUnit, GetDefaultMappings(), new HeatFlux(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the HeatFlux quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static HeatFluxInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new HeatFluxInfo(nameof(HeatFlux), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new HeatFlux(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = HeatFluxInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(HeatFlux), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new HeatFlux(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); /// /// The default base unit of HeatFlux is WattPerSquareMeter. All conversions, as defined in the , go via this value. /// - public static HeatFluxUnit DefaultBaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; + private static HeatFluxUnit DefaultBaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the HeatFlux quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.HeatFlux", typeof(HeatFlux).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for HeatFlux. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (HeatFluxUnit.BtuPerHourSquareFoot, "BtuPerHourSquareFoot", "BtusPerHourSquareFoot", BaseUnits.Undefined); yield return new (HeatFluxUnit.BtuPerMinuteSquareFoot, "BtuPerMinuteSquareFoot", "BtusPerMinuteSquareFoot", BaseUnits.Undefined); @@ -142,7 +142,7 @@ public static IEnumerable> GetDefaultMappings() static HeatFlux() { - Info = HeatFluxInfo.CreateDefault(); + Info = HeatFluxInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 82b1ac4d05..f5473f6c05 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class HeatTransferCoefficientInfo: QuantityInfo + private static class HeatTransferCoefficientInfo { - /// - public HeatTransferCoefficientInfo(string name, HeatTransferCoefficientUnit baseUnit, IEnumerable> unitMappings, HeatTransferCoefficient zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, HeatTransferCoefficient.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public HeatTransferCoefficientInfo(string name, HeatTransferCoefficientUnit baseUnit, IEnumerable> unitMappings, HeatTransferCoefficient zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, HeatTransferCoefficient.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.HeatTransferCoefficient", typeof(HeatTransferCoefficient).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the HeatTransferCoefficient quantity. - /// - /// A new instance of the class with the default settings. - public static HeatTransferCoefficientInfo CreateDefault() - { - return new HeatTransferCoefficientInfo(nameof(HeatTransferCoefficient), DefaultBaseUnit, GetDefaultMappings(), new HeatTransferCoefficient(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the HeatTransferCoefficient quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static HeatTransferCoefficientInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new HeatTransferCoefficientInfo(nameof(HeatTransferCoefficient), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new HeatTransferCoefficient(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = HeatTransferCoefficientInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(HeatTransferCoefficient), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new HeatTransferCoefficient(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][M][Θ^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -3, 0, -1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -3, 0, -1, 0, 0); /// /// The default base unit of HeatTransferCoefficient is WattPerSquareMeterKelvin. All conversions, as defined in the , go via this value. /// - public static HeatTransferCoefficientUnit DefaultBaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; + private static HeatTransferCoefficientUnit DefaultBaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; + + /// + /// The default resource manager for unit abbreviations of the HeatTransferCoefficient quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.HeatTransferCoefficient", typeof(HeatTransferCoefficient).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for HeatTransferCoefficient. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit, "BtuPerHourSquareFootDegreeFahrenheit", "BtusPerHourSquareFootDegreeFahrenheit", BaseUnits.Undefined); yield return new (HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius, "CaloriePerHourSquareMeterDegreeCelsius", "CaloriesPerHourSquareMeterDegreeCelsius", BaseUnits.Undefined); @@ -126,7 +126,7 @@ public static IEnumerable> GetDefaul static HeatTransferCoefficient() { - Info = HeatTransferCoefficientInfo.CreateDefault(); + Info = HeatTransferCoefficientInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index d9dde463be..dc9b41e874 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -68,59 +68,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class IlluminanceInfo: QuantityInfo + private static class IlluminanceInfo { - /// - public IlluminanceInfo(string name, IlluminanceUnit baseUnit, IEnumerable> unitMappings, Illuminance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Illuminance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public IlluminanceInfo(string name, IlluminanceUnit baseUnit, IEnumerable> unitMappings, Illuminance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Illuminance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Illuminance", typeof(Illuminance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Illuminance quantity. - /// - /// A new instance of the class with the default settings. - public static IlluminanceInfo CreateDefault() - { - return new IlluminanceInfo(nameof(Illuminance), DefaultBaseUnit, GetDefaultMappings(), new Illuminance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Illuminance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static IlluminanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new IlluminanceInfo(nameof(Illuminance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Illuminance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = IlluminanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Illuminance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Illuminance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-2][J]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1); /// /// The default base unit of Illuminance is Lux. All conversions, as defined in the , go via this value. /// - public static IlluminanceUnit DefaultBaseUnit { get; } = IlluminanceUnit.Lux; + private static IlluminanceUnit DefaultBaseUnit { get; } = IlluminanceUnit.Lux; + + /// + /// The default resource manager for unit abbreviations of the Illuminance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Illuminance", typeof(Illuminance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Illuminance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (IlluminanceUnit.Kilolux, "Kilolux", "Kilolux", BaseUnits.Undefined); yield return new (IlluminanceUnit.Lux, "Lux", "Lux", new BaseUnits(length: LengthUnit.Meter, luminousIntensity: LuminousIntensityUnit.Candela)); @@ -131,7 +131,7 @@ public static IEnumerable> GetDefaultMappings() static Illuminance() { - Info = IlluminanceInfo.CreateDefault(); + Info = IlluminanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index c509fa737d..6d9f60d253 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ImpulseInfo: QuantityInfo + private static class ImpulseInfo { - /// - public ImpulseInfo(string name, ImpulseUnit baseUnit, IEnumerable> unitMappings, Impulse zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Impulse.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ImpulseInfo(string name, ImpulseUnit baseUnit, IEnumerable> unitMappings, Impulse zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Impulse.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Impulse", typeof(Impulse).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Impulse quantity. - /// - /// A new instance of the class with the default settings. - public static ImpulseInfo CreateDefault() - { - return new ImpulseInfo(nameof(Impulse), DefaultBaseUnit, GetDefaultMappings(), new Impulse(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Impulse quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ImpulseInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ImpulseInfo(nameof(Impulse), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Impulse(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ImpulseInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Impulse), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Impulse(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -1, 0, 0, 0, 0); /// /// The default base unit of Impulse is NewtonSecond. All conversions, as defined in the , go via this value. /// - public static ImpulseUnit DefaultBaseUnit { get; } = ImpulseUnit.NewtonSecond; + private static ImpulseUnit DefaultBaseUnit { get; } = ImpulseUnit.NewtonSecond; + + /// + /// The default resource manager for unit abbreviations of the Impulse quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Impulse", typeof(Impulse).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Impulse. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ImpulseUnit.CentinewtonSecond, "CentinewtonSecond", "CentinewtonSeconds", new BaseUnits(length: LengthUnit.Centimeter, mass: MassUnit.Kilogram, time: DurationUnit.Second)); yield return new (ImpulseUnit.DecanewtonSecond, "DecanewtonSecond", "DecanewtonSeconds", new BaseUnits(length: LengthUnit.Decameter, mass: MassUnit.Kilogram, time: DurationUnit.Second)); @@ -134,7 +134,7 @@ public static IEnumerable> GetDefaultMappings() static Impulse() { - Info = ImpulseInfo.CreateDefault(); + Info = ImpulseInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 163423b6e8..7aa05c5f17 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class InformationInfo: QuantityInfo + private static class InformationInfo { - /// - public InformationInfo(string name, InformationUnit baseUnit, IEnumerable> unitMappings, Information zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Information.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public InformationInfo(string name, InformationUnit baseUnit, IEnumerable> unitMappings, Information zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Information.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Information", typeof(Information).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Information quantity. - /// - /// A new instance of the class with the default settings. - public static InformationInfo CreateDefault() - { - return new InformationInfo(nameof(Information), DefaultBaseUnit, GetDefaultMappings(), new Information(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Information quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static InformationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new InformationInfo(nameof(Information), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Information(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = InformationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Information), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Information(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of Information is Bit. All conversions, as defined in the , go via this value. /// - public static InformationUnit DefaultBaseUnit { get; } = InformationUnit.Bit; + private static InformationUnit DefaultBaseUnit { get; } = InformationUnit.Bit; + + /// + /// The default resource manager for unit abbreviations of the Information quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Information", typeof(Information).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Information. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (InformationUnit.Bit, "Bit", "Bits", BaseUnits.Undefined); yield return new (InformationUnit.Byte, "Byte", "Bytes", BaseUnits.Undefined); @@ -160,7 +160,7 @@ public static IEnumerable> GetDefaultMappings() static Information() { - Info = InformationInfo.CreateDefault(); + Info = InformationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 737e575488..247b5e2844 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class IrradianceInfo: QuantityInfo + private static class IrradianceInfo { - /// - public IrradianceInfo(string name, IrradianceUnit baseUnit, IEnumerable> unitMappings, Irradiance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Irradiance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public IrradianceInfo(string name, IrradianceUnit baseUnit, IEnumerable> unitMappings, Irradiance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Irradiance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Irradiance", typeof(Irradiance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Irradiance quantity. - /// - /// A new instance of the class with the default settings. - public static IrradianceInfo CreateDefault() - { - return new IrradianceInfo(nameof(Irradiance), DefaultBaseUnit, GetDefaultMappings(), new Irradiance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Irradiance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static IrradianceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new IrradianceInfo(nameof(Irradiance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Irradiance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = IrradianceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Irradiance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Irradiance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); /// /// The default base unit of Irradiance is WattPerSquareMeter. All conversions, as defined in the , go via this value. /// - public static IrradianceUnit DefaultBaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; + private static IrradianceUnit DefaultBaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the Irradiance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Irradiance", typeof(Irradiance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Irradiance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (IrradianceUnit.KilowattPerSquareCentimeter, "KilowattPerSquareCentimeter", "KilowattsPerSquareCentimeter", BaseUnits.Undefined); yield return new (IrradianceUnit.KilowattPerSquareMeter, "KilowattPerSquareMeter", "KilowattsPerSquareMeter", BaseUnits.Undefined); @@ -135,7 +135,7 @@ public static IEnumerable> GetDefaultMappings() static Irradiance() { - Info = IrradianceInfo.CreateDefault(); + Info = IrradianceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index c35a0a557c..ee3ff3146d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class IrradiationInfo: QuantityInfo + private static class IrradiationInfo { - /// - public IrradiationInfo(string name, IrradiationUnit baseUnit, IEnumerable> unitMappings, Irradiation zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Irradiation.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public IrradiationInfo(string name, IrradiationUnit baseUnit, IEnumerable> unitMappings, Irradiation zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Irradiation.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Irradiation", typeof(Irradiation).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Irradiation quantity. - /// - /// A new instance of the class with the default settings. - public static IrradiationInfo CreateDefault() - { - return new IrradiationInfo(nameof(Irradiation), DefaultBaseUnit, GetDefaultMappings(), new Irradiation(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Irradiation quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static IrradiationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new IrradiationInfo(nameof(Irradiation), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Irradiation(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = IrradiationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Irradiation), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Irradiation(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); /// /// The default base unit of Irradiation is JoulePerSquareMeter. All conversions, as defined in the , go via this value. /// - public static IrradiationUnit DefaultBaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; + private static IrradiationUnit DefaultBaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the Irradiation quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Irradiation", typeof(Irradiation).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Irradiation. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (IrradiationUnit.BtuPerSquareFoot, "BtuPerSquareFoot", "BtusPerSquareFoot", BaseUnits.Undefined); yield return new (IrradiationUnit.JoulePerSquareCentimeter, "JoulePerSquareCentimeter", "JoulesPerSquareCentimeter", BaseUnits.Undefined); @@ -133,7 +133,7 @@ public static IEnumerable> GetDefaultMappings() static Irradiation() { - Info = IrradiationInfo.CreateDefault(); + Info = IrradiationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 5d4fb14f26..a56ca04301 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class JerkInfo: QuantityInfo + private static class JerkInfo { - /// - public JerkInfo(string name, JerkUnit baseUnit, IEnumerable> unitMappings, Jerk zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Jerk.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public JerkInfo(string name, JerkUnit baseUnit, IEnumerable> unitMappings, Jerk zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Jerk.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Jerk", typeof(Jerk).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Jerk quantity. - /// - /// A new instance of the class with the default settings. - public static JerkInfo CreateDefault() - { - return new JerkInfo(nameof(Jerk), DefaultBaseUnit, GetDefaultMappings(), new Jerk(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Jerk quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static JerkInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new JerkInfo(nameof(Jerk), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Jerk(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = JerkInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Jerk), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Jerk(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -3, 0, 0, 0, 0); /// /// The default base unit of Jerk is MeterPerSecondCubed. All conversions, as defined in the , go via this value. /// - public static JerkUnit DefaultBaseUnit { get; } = JerkUnit.MeterPerSecondCubed; + private static JerkUnit DefaultBaseUnit { get; } = JerkUnit.MeterPerSecondCubed; + + /// + /// The default resource manager for unit abbreviations of the Jerk quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Jerk", typeof(Jerk).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Jerk. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (JerkUnit.CentimeterPerSecondCubed, "CentimeterPerSecondCubed", "CentimetersPerSecondCubed", new BaseUnits(length: LengthUnit.Centimeter, time: DurationUnit.Second)); yield return new (JerkUnit.DecimeterPerSecondCubed, "DecimeterPerSecondCubed", "DecimetersPerSecondCubed", new BaseUnits(length: LengthUnit.Decimeter, time: DurationUnit.Second)); @@ -135,7 +135,7 @@ public static IEnumerable> GetDefaultMappings() static Jerk() { - Info = JerkInfo.CreateDefault(); + Info = JerkInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 8a136629e7..4687aee42e 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -71,59 +71,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class KinematicViscosityInfo: QuantityInfo + private static class KinematicViscosityInfo { - /// - public KinematicViscosityInfo(string name, KinematicViscosityUnit baseUnit, IEnumerable> unitMappings, KinematicViscosity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, KinematicViscosity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public KinematicViscosityInfo(string name, KinematicViscosityUnit baseUnit, IEnumerable> unitMappings, KinematicViscosity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, KinematicViscosity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.KinematicViscosity", typeof(KinematicViscosity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the KinematicViscosity quantity. - /// - /// A new instance of the class with the default settings. - public static KinematicViscosityInfo CreateDefault() - { - return new KinematicViscosityInfo(nameof(KinematicViscosity), DefaultBaseUnit, GetDefaultMappings(), new KinematicViscosity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the KinematicViscosity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static KinematicViscosityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new KinematicViscosityInfo(nameof(KinematicViscosity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new KinematicViscosity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = KinematicViscosityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(KinematicViscosity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new KinematicViscosity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -1, 0, 0, 0, 0); /// /// The default base unit of KinematicViscosity is SquareMeterPerSecond. All conversions, as defined in the , go via this value. /// - public static KinematicViscosityUnit DefaultBaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; + private static KinematicViscosityUnit DefaultBaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; + + /// + /// The default resource manager for unit abbreviations of the KinematicViscosity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.KinematicViscosity", typeof(KinematicViscosity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for KinematicViscosity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (KinematicViscosityUnit.Centistokes, "Centistokes", "Centistokes", BaseUnits.Undefined); yield return new (KinematicViscosityUnit.Decistokes, "Decistokes", "Decistokes", BaseUnits.Undefined); @@ -139,7 +139,7 @@ public static IEnumerable> GetDefaultMapp static KinematicViscosity() { - Info = KinematicViscosityInfo.CreateDefault(); + Info = KinematicViscosityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index 65924e7035..c4bade32ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LeakRateInfo: QuantityInfo + private static class LeakRateInfo { - /// - public LeakRateInfo(string name, LeakRateUnit baseUnit, IEnumerable> unitMappings, LeakRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, LeakRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LeakRateInfo(string name, LeakRateUnit baseUnit, IEnumerable> unitMappings, LeakRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, LeakRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.LeakRate", typeof(LeakRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the LeakRate quantity. - /// - /// A new instance of the class with the default settings. - public static LeakRateInfo CreateDefault() - { - return new LeakRateInfo(nameof(LeakRate), DefaultBaseUnit, GetDefaultMappings(), new LeakRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the LeakRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LeakRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LeakRateInfo(nameof(LeakRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new LeakRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LeakRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(LeakRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new LeakRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); /// /// The default base unit of LeakRate is PascalCubicMeterPerSecond. All conversions, as defined in the , go via this value. /// - public static LeakRateUnit DefaultBaseUnit { get; } = LeakRateUnit.PascalCubicMeterPerSecond; + private static LeakRateUnit DefaultBaseUnit { get; } = LeakRateUnit.PascalCubicMeterPerSecond; + + /// + /// The default resource manager for unit abbreviations of the LeakRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.LeakRate", typeof(LeakRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for LeakRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LeakRateUnit.MillibarLiterPerSecond, "MillibarLiterPerSecond", "MillibarLitersPerSecond", BaseUnits.Undefined); yield return new (LeakRateUnit.PascalCubicMeterPerSecond, "PascalCubicMeterPerSecond", "PascalCubicMetersPerSecond", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second)); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefaultMappings() static LeakRate() { - Info = LeakRateInfo.CreateDefault(); + Info = LeakRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index d892e357f0..a5c3a53469 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -82,59 +82,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LengthInfo: QuantityInfo + private static class LengthInfo { - /// - public LengthInfo(string name, LengthUnit baseUnit, IEnumerable> unitMappings, Length zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Length.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LengthInfo(string name, LengthUnit baseUnit, IEnumerable> unitMappings, Length zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Length.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Length", typeof(Length).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Length quantity. - /// - /// A new instance of the class with the default settings. - public static LengthInfo CreateDefault() - { - return new LengthInfo(nameof(Length), DefaultBaseUnit, GetDefaultMappings(), new Length(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Length quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LengthInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LengthInfo(nameof(Length), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Length(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LengthInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Length), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Length(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, 0, 0, 0, 0, 0); /// /// The default base unit of Length is Meter. All conversions, as defined in the , go via this value. /// - public static LengthUnit DefaultBaseUnit { get; } = LengthUnit.Meter; + private static LengthUnit DefaultBaseUnit { get; } = LengthUnit.Meter; + + /// + /// The default resource manager for unit abbreviations of the Length quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Length", typeof(Length).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Length. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LengthUnit.Angstrom, "Angstrom", "Angstroms", new BaseUnits(length: LengthUnit.Angstrom)); yield return new (LengthUnit.AstronomicalUnit, "AstronomicalUnit", "AstronomicalUnits", new BaseUnits(length: LengthUnit.AstronomicalUnit)); @@ -183,7 +183,7 @@ public static IEnumerable> GetDefaultMappings() static Length() { - Info = LengthInfo.CreateDefault(); + Info = LengthInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 31b3436d1a..5fe58aa3db 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LevelInfo: QuantityInfo + private static class LevelInfo { - /// - public LevelInfo(string name, LevelUnit baseUnit, IEnumerable> unitMappings, Level zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Level.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LevelInfo(string name, LevelUnit baseUnit, IEnumerable> unitMappings, Level zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Level.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Level", typeof(Level).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Level quantity. - /// - /// A new instance of the class with the default settings. - public static LevelInfo CreateDefault() - { - return new LevelInfo(nameof(Level), DefaultBaseUnit, GetDefaultMappings(), new Level(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Level quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LevelInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LevelInfo(nameof(Level), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Level(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LevelInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Level), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Level(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of Level is Decibel. All conversions, as defined in the , go via this value. /// - public static LevelUnit DefaultBaseUnit { get; } = LevelUnit.Decibel; + private static LevelUnit DefaultBaseUnit { get; } = LevelUnit.Decibel; + + /// + /// The default resource manager for unit abbreviations of the Level quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Level", typeof(Level).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Level. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LevelUnit.Decibel, "Decibel", "Decibels", BaseUnits.Undefined); yield return new (LevelUnit.Neper, "Neper", "Nepers", BaseUnits.Undefined); @@ -123,7 +123,7 @@ public static IEnumerable> GetDefaultMappings() static Level() { - Info = LevelInfo.CreateDefault(); + Info = LevelInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 12a3814e3e..b5499d1245 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -70,59 +70,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LinearDensityInfo: QuantityInfo + private static class LinearDensityInfo { - /// - public LinearDensityInfo(string name, LinearDensityUnit baseUnit, IEnumerable> unitMappings, LinearDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, LinearDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LinearDensityInfo(string name, LinearDensityUnit baseUnit, IEnumerable> unitMappings, LinearDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, LinearDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.LinearDensity", typeof(LinearDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the LinearDensity quantity. - /// - /// A new instance of the class with the default settings. - public static LinearDensityInfo CreateDefault() - { - return new LinearDensityInfo(nameof(LinearDensity), DefaultBaseUnit, GetDefaultMappings(), new LinearDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the LinearDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LinearDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LinearDensityInfo(nameof(LinearDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new LinearDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LinearDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(LinearDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new LinearDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, 0, 0, 0, 0, 0); /// /// The default base unit of LinearDensity is KilogramPerMeter. All conversions, as defined in the , go via this value. /// - public static LinearDensityUnit DefaultBaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; + private static LinearDensityUnit DefaultBaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; + + /// + /// The default resource manager for unit abbreviations of the LinearDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.LinearDensity", typeof(LinearDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for LinearDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LinearDensityUnit.GramPerCentimeter, "GramPerCentimeter", "GramsPerCentimeter", new BaseUnits(length: LengthUnit.Centimeter, mass: MassUnit.Gram)); yield return new (LinearDensityUnit.GramPerFoot, "GramPerFoot", "GramsPerFoot", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Gram)); @@ -147,7 +147,7 @@ public static IEnumerable> GetDefaultMappings( static LinearDensity() { - Info = LinearDensityInfo.CreateDefault(); + Info = LinearDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 8dc83747c1..c9e7b8e9d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LinearPowerDensityInfo: QuantityInfo + private static class LinearPowerDensityInfo { - /// - public LinearPowerDensityInfo(string name, LinearPowerDensityUnit baseUnit, IEnumerable> unitMappings, LinearPowerDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, LinearPowerDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LinearPowerDensityInfo(string name, LinearPowerDensityUnit baseUnit, IEnumerable> unitMappings, LinearPowerDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, LinearPowerDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.LinearPowerDensity", typeof(LinearPowerDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the LinearPowerDensity quantity. - /// - /// A new instance of the class with the default settings. - public static LinearPowerDensityInfo CreateDefault() - { - return new LinearPowerDensityInfo(nameof(LinearPowerDensity), DefaultBaseUnit, GetDefaultMappings(), new LinearPowerDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the LinearPowerDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LinearPowerDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LinearPowerDensityInfo(nameof(LinearPowerDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new LinearPowerDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LinearPowerDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(LinearPowerDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new LinearPowerDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); /// /// The default base unit of LinearPowerDensity is WattPerMeter. All conversions, as defined in the , go via this value. /// - public static LinearPowerDensityUnit DefaultBaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; + private static LinearPowerDensityUnit DefaultBaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; + + /// + /// The default resource manager for unit abbreviations of the LinearPowerDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.LinearPowerDensity", typeof(LinearPowerDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for LinearPowerDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LinearPowerDensityUnit.GigawattPerCentimeter, "GigawattPerCentimeter", "GigawattsPerCentimeter", BaseUnits.Undefined); yield return new (LinearPowerDensityUnit.GigawattPerFoot, "GigawattPerFoot", "GigawattsPerFoot", BaseUnits.Undefined); @@ -149,7 +149,7 @@ public static IEnumerable> GetDefaultMapp static LinearPowerDensity() { - Info = LinearPowerDensityInfo.CreateDefault(); + Info = LinearPowerDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index d961f016f9..724fe8b566 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -68,59 +68,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LuminanceInfo: QuantityInfo + private static class LuminanceInfo { - /// - public LuminanceInfo(string name, LuminanceUnit baseUnit, IEnumerable> unitMappings, Luminance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Luminance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LuminanceInfo(string name, LuminanceUnit baseUnit, IEnumerable> unitMappings, Luminance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Luminance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Luminance", typeof(Luminance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Luminance quantity. - /// - /// A new instance of the class with the default settings. - public static LuminanceInfo CreateDefault() - { - return new LuminanceInfo(nameof(Luminance), DefaultBaseUnit, GetDefaultMappings(), new Luminance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Luminance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LuminanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LuminanceInfo(nameof(Luminance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Luminance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LuminanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Luminance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Luminance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-2][J]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1); /// /// The default base unit of Luminance is CandelaPerSquareMeter. All conversions, as defined in the , go via this value. /// - public static LuminanceUnit DefaultBaseUnit { get; } = LuminanceUnit.CandelaPerSquareMeter; + private static LuminanceUnit DefaultBaseUnit { get; } = LuminanceUnit.CandelaPerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the Luminance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Luminance", typeof(Luminance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Luminance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LuminanceUnit.CandelaPerSquareFoot, "CandelaPerSquareFoot", "CandelasPerSquareFoot", BaseUnits.Undefined); yield return new (LuminanceUnit.CandelaPerSquareInch, "CandelaPerSquareInch", "CandelasPerSquareInch", BaseUnits.Undefined); @@ -137,7 +137,7 @@ public static IEnumerable> GetDefaultMappings() static Luminance() { - Info = LuminanceInfo.CreateDefault(); + Info = LuminanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index b8bedf6ab1..94346e1d09 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LuminosityInfo: QuantityInfo + private static class LuminosityInfo { - /// - public LuminosityInfo(string name, LuminosityUnit baseUnit, IEnumerable> unitMappings, Luminosity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Luminosity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LuminosityInfo(string name, LuminosityUnit baseUnit, IEnumerable> unitMappings, Luminosity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Luminosity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Luminosity", typeof(Luminosity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Luminosity quantity. - /// - /// A new instance of the class with the default settings. - public static LuminosityInfo CreateDefault() - { - return new LuminosityInfo(nameof(Luminosity), DefaultBaseUnit, GetDefaultMappings(), new Luminosity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Luminosity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LuminosityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LuminosityInfo(nameof(Luminosity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Luminosity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LuminosityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Luminosity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Luminosity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); /// /// The default base unit of Luminosity is Watt. All conversions, as defined in the , go via this value. /// - public static LuminosityUnit DefaultBaseUnit { get; } = LuminosityUnit.Watt; + private static LuminosityUnit DefaultBaseUnit { get; } = LuminosityUnit.Watt; + + /// + /// The default resource manager for unit abbreviations of the Luminosity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Luminosity", typeof(Luminosity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Luminosity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LuminosityUnit.Decawatt, "Decawatt", "Decawatts", BaseUnits.Undefined); yield return new (LuminosityUnit.Deciwatt, "Deciwatt", "Deciwatts", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Hectogram, time: DurationUnit.Second)); @@ -138,7 +138,7 @@ public static IEnumerable> GetDefaultMappings() static Luminosity() { - Info = LuminosityInfo.CreateDefault(); + Info = LuminosityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 68afbb96b7..27418d6f9d 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -69,59 +69,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LuminousFluxInfo: QuantityInfo + private static class LuminousFluxInfo { - /// - public LuminousFluxInfo(string name, LuminousFluxUnit baseUnit, IEnumerable> unitMappings, LuminousFlux zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, LuminousFlux.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LuminousFluxInfo(string name, LuminousFluxUnit baseUnit, IEnumerable> unitMappings, LuminousFlux zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, LuminousFlux.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.LuminousFlux", typeof(LuminousFlux).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the LuminousFlux quantity. - /// - /// A new instance of the class with the default settings. - public static LuminousFluxInfo CreateDefault() - { - return new LuminousFluxInfo(nameof(LuminousFlux), DefaultBaseUnit, GetDefaultMappings(), new LuminousFlux(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the LuminousFlux quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LuminousFluxInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LuminousFluxInfo(nameof(LuminousFlux), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new LuminousFlux(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LuminousFluxInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(LuminousFlux), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new LuminousFlux(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [J]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); /// /// The default base unit of LuminousFlux is Lumen. All conversions, as defined in the , go via this value. /// - public static LuminousFluxUnit DefaultBaseUnit { get; } = LuminousFluxUnit.Lumen; + private static LuminousFluxUnit DefaultBaseUnit { get; } = LuminousFluxUnit.Lumen; + + /// + /// The default resource manager for unit abbreviations of the LuminousFlux quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.LuminousFlux", typeof(LuminousFlux).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for LuminousFlux. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LuminousFluxUnit.Lumen, "Lumen", "Lumens", new BaseUnits(luminousIntensity: LuminousIntensityUnit.Candela)); } @@ -129,7 +129,7 @@ public static IEnumerable> GetDefaultMappings() static LuminousFlux() { - Info = LuminousFluxInfo.CreateDefault(); + Info = LuminousFluxInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index daeb69160c..3dcc442b03 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -69,59 +69,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class LuminousIntensityInfo: QuantityInfo + private static class LuminousIntensityInfo { - /// - public LuminousIntensityInfo(string name, LuminousIntensityUnit baseUnit, IEnumerable> unitMappings, LuminousIntensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, LuminousIntensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public LuminousIntensityInfo(string name, LuminousIntensityUnit baseUnit, IEnumerable> unitMappings, LuminousIntensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, LuminousIntensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.LuminousIntensity", typeof(LuminousIntensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the LuminousIntensity quantity. - /// - /// A new instance of the class with the default settings. - public static LuminousIntensityInfo CreateDefault() - { - return new LuminousIntensityInfo(nameof(LuminousIntensity), DefaultBaseUnit, GetDefaultMappings(), new LuminousIntensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the LuminousIntensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static LuminousIntensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new LuminousIntensityInfo(nameof(LuminousIntensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new LuminousIntensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = LuminousIntensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(LuminousIntensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new LuminousIntensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [J]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); /// /// The default base unit of LuminousIntensity is Candela. All conversions, as defined in the , go via this value. /// - public static LuminousIntensityUnit DefaultBaseUnit { get; } = LuminousIntensityUnit.Candela; + private static LuminousIntensityUnit DefaultBaseUnit { get; } = LuminousIntensityUnit.Candela; + + /// + /// The default resource manager for unit abbreviations of the LuminousIntensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.LuminousIntensity", typeof(LuminousIntensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for LuminousIntensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (LuminousIntensityUnit.Candela, "Candela", "Candela", new BaseUnits(luminousIntensity: LuminousIntensityUnit.Candela)); } @@ -129,7 +129,7 @@ public static IEnumerable> GetDefaultMappi static LuminousIntensity() { - Info = LuminousIntensityInfo.CreateDefault(); + Info = LuminousIntensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index facd6fe94e..333b3aeab7 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MagneticFieldInfo: QuantityInfo + private static class MagneticFieldInfo { - /// - public MagneticFieldInfo(string name, MagneticFieldUnit baseUnit, IEnumerable> unitMappings, MagneticField zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MagneticField.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MagneticFieldInfo(string name, MagneticFieldUnit baseUnit, IEnumerable> unitMappings, MagneticField zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MagneticField.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MagneticField", typeof(MagneticField).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MagneticField quantity. - /// - /// A new instance of the class with the default settings. - public static MagneticFieldInfo CreateDefault() - { - return new MagneticFieldInfo(nameof(MagneticField), DefaultBaseUnit, GetDefaultMappings(), new MagneticField(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MagneticField quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MagneticFieldInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MagneticFieldInfo(nameof(MagneticField), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MagneticField(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MagneticFieldInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MagneticField), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MagneticField(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][M][I^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -2, -1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -2, -1, 0, 0, 0); /// /// The default base unit of MagneticField is Tesla. All conversions, as defined in the , go via this value. /// - public static MagneticFieldUnit DefaultBaseUnit { get; } = MagneticFieldUnit.Tesla; + private static MagneticFieldUnit DefaultBaseUnit { get; } = MagneticFieldUnit.Tesla; + + /// + /// The default resource manager for unit abbreviations of the MagneticField quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MagneticField", typeof(MagneticField).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MagneticField. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MagneticFieldUnit.Gauss, "Gauss", "Gausses", BaseUnits.Undefined); yield return new (MagneticFieldUnit.Microtesla, "Microtesla", "Microteslas", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Milligram, current: ElectricCurrentUnit.Ampere)); @@ -130,7 +130,7 @@ public static IEnumerable> GetDefaultMappings( static MagneticField() { - Info = MagneticFieldInfo.CreateDefault(); + Info = MagneticFieldInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 0bb44b7674..c3bdba4f0b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MagneticFluxInfo: QuantityInfo + private static class MagneticFluxInfo { - /// - public MagneticFluxInfo(string name, MagneticFluxUnit baseUnit, IEnumerable> unitMappings, MagneticFlux zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MagneticFlux.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MagneticFluxInfo(string name, MagneticFluxUnit baseUnit, IEnumerable> unitMappings, MagneticFlux zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MagneticFlux.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MagneticFlux", typeof(MagneticFlux).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MagneticFlux quantity. - /// - /// A new instance of the class with the default settings. - public static MagneticFluxInfo CreateDefault() - { - return new MagneticFluxInfo(nameof(MagneticFlux), DefaultBaseUnit, GetDefaultMappings(), new MagneticFlux(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MagneticFlux quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MagneticFluxInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MagneticFluxInfo(nameof(MagneticFlux), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MagneticFlux(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MagneticFluxInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MagneticFlux), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MagneticFlux(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M][I^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, -1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, -1, 0, 0, 0); /// /// The default base unit of MagneticFlux is Weber. All conversions, as defined in the , go via this value. /// - public static MagneticFluxUnit DefaultBaseUnit { get; } = MagneticFluxUnit.Weber; + private static MagneticFluxUnit DefaultBaseUnit { get; } = MagneticFluxUnit.Weber; + + /// + /// The default resource manager for unit abbreviations of the MagneticFlux quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MagneticFlux", typeof(MagneticFlux).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MagneticFlux. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MagneticFluxUnit.Weber, "Weber", "Webers", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings() static MagneticFlux() { - Info = MagneticFluxInfo.CreateDefault(); + Info = MagneticFluxInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index fd806ebd43..33816029c3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MagnetizationInfo: QuantityInfo + private static class MagnetizationInfo { - /// - public MagnetizationInfo(string name, MagnetizationUnit baseUnit, IEnumerable> unitMappings, Magnetization zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Magnetization.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MagnetizationInfo(string name, MagnetizationUnit baseUnit, IEnumerable> unitMappings, Magnetization zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Magnetization.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Magnetization", typeof(Magnetization).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Magnetization quantity. - /// - /// A new instance of the class with the default settings. - public static MagnetizationInfo CreateDefault() - { - return new MagnetizationInfo(nameof(Magnetization), DefaultBaseUnit, GetDefaultMappings(), new Magnetization(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Magnetization quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MagnetizationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MagnetizationInfo(nameof(Magnetization), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Magnetization(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MagnetizationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Magnetization), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Magnetization(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-1][I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 0, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 0, 1, 0, 0, 0); /// /// The default base unit of Magnetization is AmperePerMeter. All conversions, as defined in the , go via this value. /// - public static MagnetizationUnit DefaultBaseUnit { get; } = MagnetizationUnit.AmperePerMeter; + private static MagnetizationUnit DefaultBaseUnit { get; } = MagnetizationUnit.AmperePerMeter; + + /// + /// The default resource manager for unit abbreviations of the Magnetization quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Magnetization", typeof(Magnetization).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Magnetization. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MagnetizationUnit.AmperePerMeter, "AmperePerMeter", "AmperesPerMeter", new BaseUnits(length: LengthUnit.Meter, current: ElectricCurrentUnit.Ampere)); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings( static Magnetization() { - Info = MagnetizationInfo.CreateDefault(); + Info = MagnetizationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index d9c3a2026a..c56eb394f0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -80,59 +80,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MassInfo: QuantityInfo + private static class MassInfo { - /// - public MassInfo(string name, MassUnit baseUnit, IEnumerable> unitMappings, Mass zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Mass.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MassInfo(string name, MassUnit baseUnit, IEnumerable> unitMappings, Mass zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Mass.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Mass", typeof(Mass).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Mass quantity. - /// - /// A new instance of the class with the default settings. - public static MassInfo CreateDefault() - { - return new MassInfo(nameof(Mass), DefaultBaseUnit, GetDefaultMappings(), new Mass(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Mass quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MassInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MassInfo(nameof(Mass), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Mass(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MassInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Mass), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Mass(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, 0, 0, 0, 0, 0); /// /// The default base unit of Mass is Kilogram. All conversions, as defined in the , go via this value. /// - public static MassUnit DefaultBaseUnit { get; } = MassUnit.Kilogram; + private static MassUnit DefaultBaseUnit { get; } = MassUnit.Kilogram; + + /// + /// The default resource manager for unit abbreviations of the Mass quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Mass", typeof(Mass).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Mass. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MassUnit.Centigram, "Centigram", "Centigrams", new BaseUnits(mass: MassUnit.Centigram)); yield return new (MassUnit.Decagram, "Decagram", "Decagrams", new BaseUnits(mass: MassUnit.Decagram)); @@ -166,7 +166,7 @@ public static IEnumerable> GetDefaultMappings() static Mass() { - Info = MassInfo.CreateDefault(); + Info = MassInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index e85070f6aa..ea1fffc096 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -72,59 +72,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MassConcentrationInfo: QuantityInfo + private static class MassConcentrationInfo { - /// - public MassConcentrationInfo(string name, MassConcentrationUnit baseUnit, IEnumerable> unitMappings, MassConcentration zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MassConcentration.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MassConcentrationInfo(string name, MassConcentrationUnit baseUnit, IEnumerable> unitMappings, MassConcentration zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MassConcentration.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MassConcentration", typeof(MassConcentration).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MassConcentration quantity. - /// - /// A new instance of the class with the default settings. - public static MassConcentrationInfo CreateDefault() - { - return new MassConcentrationInfo(nameof(MassConcentration), DefaultBaseUnit, GetDefaultMappings(), new MassConcentration(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MassConcentration quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MassConcentrationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MassConcentrationInfo(nameof(MassConcentration), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MassConcentration(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MassConcentrationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MassConcentration), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MassConcentration(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-3][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); /// /// The default base unit of MassConcentration is KilogramPerCubicMeter. All conversions, as defined in the , go via this value. /// - public static MassConcentrationUnit DefaultBaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; + private static MassConcentrationUnit DefaultBaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the MassConcentration quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MassConcentration", typeof(MassConcentration).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MassConcentration. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MassConcentrationUnit.CentigramPerDeciliter, "CentigramPerDeciliter", "CentigramsPerDeciliter", BaseUnits.Undefined); yield return new (MassConcentrationUnit.CentigramPerLiter, "CentigramPerLiter", "CentigramsPerLiter", new BaseUnits(length: LengthUnit.Decimeter, mass: MassUnit.Centigram)); @@ -180,7 +180,7 @@ public static IEnumerable> GetDefaultMappi static MassConcentration() { - Info = MassConcentrationInfo.CreateDefault(); + Info = MassConcentrationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index bd5759e276..6b42e9edde 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -74,59 +74,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MassFlowInfo: QuantityInfo + private static class MassFlowInfo { - /// - public MassFlowInfo(string name, MassFlowUnit baseUnit, IEnumerable> unitMappings, MassFlow zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MassFlow.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MassFlowInfo(string name, MassFlowUnit baseUnit, IEnumerable> unitMappings, MassFlow zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MassFlow.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MassFlow", typeof(MassFlow).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MassFlow quantity. - /// - /// A new instance of the class with the default settings. - public static MassFlowInfo CreateDefault() - { - return new MassFlowInfo(nameof(MassFlow), DefaultBaseUnit, GetDefaultMappings(), new MassFlow(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MassFlow quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MassFlowInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MassFlowInfo(nameof(MassFlow), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MassFlow(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MassFlowInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MassFlow), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MassFlow(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); /// /// The default base unit of MassFlow is GramPerSecond. All conversions, as defined in the , go via this value. /// - public static MassFlowUnit DefaultBaseUnit { get; } = MassFlowUnit.GramPerSecond; + private static MassFlowUnit DefaultBaseUnit { get; } = MassFlowUnit.GramPerSecond; + + /// + /// The default resource manager for unit abbreviations of the MassFlow quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MassFlow", typeof(MassFlow).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MassFlow. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MassFlowUnit.CentigramPerDay, "CentigramPerDay", "CentigramsPerDay", new BaseUnits(mass: MassUnit.Centigram, time: DurationUnit.Day)); yield return new (MassFlowUnit.CentigramPerSecond, "CentigramPerSecond", "CentigramsPerSecond", new BaseUnits(mass: MassUnit.Centigram, time: DurationUnit.Second)); @@ -166,7 +166,7 @@ public static IEnumerable> GetDefaultMappings() static MassFlow() { - Info = MassFlowInfo.CreateDefault(); + Info = MassFlowInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index f5d3c92fe3..6e06c9b293 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -67,59 +67,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MassFluxInfo: QuantityInfo + private static class MassFluxInfo { - /// - public MassFluxInfo(string name, MassFluxUnit baseUnit, IEnumerable> unitMappings, MassFlux zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MassFlux.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MassFluxInfo(string name, MassFluxUnit baseUnit, IEnumerable> unitMappings, MassFlux zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MassFlux.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MassFlux", typeof(MassFlux).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MassFlux quantity. - /// - /// A new instance of the class with the default settings. - public static MassFluxInfo CreateDefault() - { - return new MassFluxInfo(nameof(MassFlux), DefaultBaseUnit, GetDefaultMappings(), new MassFlux(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MassFlux quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MassFluxInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MassFluxInfo(nameof(MassFlux), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MassFlux(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MassFluxInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MassFlux), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MassFlux(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L^-2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0); /// /// The default base unit of MassFlux is KilogramPerSecondPerSquareMeter. All conversions, as defined in the , go via this value. /// - public static MassFluxUnit DefaultBaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; + private static MassFluxUnit DefaultBaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the MassFlux quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MassFlux", typeof(MassFlux).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MassFlux. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MassFluxUnit.GramPerHourPerSquareCentimeter, "GramPerHourPerSquareCentimeter", "GramsPerHourPerSquareCentimeter", new BaseUnits(length: LengthUnit.Centimeter, mass: MassUnit.Gram, time: DurationUnit.Hour)); yield return new (MassFluxUnit.GramPerHourPerSquareMeter, "GramPerHourPerSquareMeter", "GramsPerHourPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Gram, time: DurationUnit.Hour)); @@ -138,7 +138,7 @@ public static IEnumerable> GetDefaultMappings() static MassFlux() { - Info = MassFluxInfo.CreateDefault(); + Info = MassFluxInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index d721908222..0dd239092f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -68,59 +68,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MassFractionInfo: QuantityInfo + private static class MassFractionInfo { - /// - public MassFractionInfo(string name, MassFractionUnit baseUnit, IEnumerable> unitMappings, MassFraction zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MassFraction.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MassFractionInfo(string name, MassFractionUnit baseUnit, IEnumerable> unitMappings, MassFraction zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MassFraction.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MassFraction", typeof(MassFraction).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MassFraction quantity. - /// - /// A new instance of the class with the default settings. - public static MassFractionInfo CreateDefault() - { - return new MassFractionInfo(nameof(MassFraction), DefaultBaseUnit, GetDefaultMappings(), new MassFraction(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MassFraction quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MassFractionInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MassFractionInfo(nameof(MassFraction), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MassFraction(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MassFractionInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MassFraction), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MassFraction(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of MassFraction is DecimalFraction. All conversions, as defined in the , go via this value. /// - public static MassFractionUnit DefaultBaseUnit { get; } = MassFractionUnit.DecimalFraction; + private static MassFractionUnit DefaultBaseUnit { get; } = MassFractionUnit.DecimalFraction; + + /// + /// The default resource manager for unit abbreviations of the MassFraction quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MassFraction", typeof(MassFraction).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MassFraction. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MassFractionUnit.CentigramPerGram, "CentigramPerGram", "CentigramsPerGram", BaseUnits.Undefined); yield return new (MassFractionUnit.CentigramPerKilogram, "CentigramPerKilogram", "CentigramsPerKilogram", BaseUnits.Undefined); @@ -151,7 +151,7 @@ public static IEnumerable> GetDefaultMappings() static MassFraction() { - Info = MassFractionInfo.CreateDefault(); + Info = MassFractionInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index b53b9be759..3f23324e23 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MassMomentOfInertiaInfo: QuantityInfo + private static class MassMomentOfInertiaInfo { - /// - public MassMomentOfInertiaInfo(string name, MassMomentOfInertiaUnit baseUnit, IEnumerable> unitMappings, MassMomentOfInertia zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MassMomentOfInertia.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MassMomentOfInertiaInfo(string name, MassMomentOfInertiaUnit baseUnit, IEnumerable> unitMappings, MassMomentOfInertia zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MassMomentOfInertia.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MassMomentOfInertia", typeof(MassMomentOfInertia).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MassMomentOfInertia quantity. - /// - /// A new instance of the class with the default settings. - public static MassMomentOfInertiaInfo CreateDefault() - { - return new MassMomentOfInertiaInfo(nameof(MassMomentOfInertia), DefaultBaseUnit, GetDefaultMappings(), new MassMomentOfInertia(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MassMomentOfInertia quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MassMomentOfInertiaInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MassMomentOfInertiaInfo(nameof(MassMomentOfInertia), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MassMomentOfInertia(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MassMomentOfInertiaInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MassMomentOfInertia), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MassMomentOfInertia(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, 0, 0, 0, 0, 0); /// /// The default base unit of MassMomentOfInertia is KilogramSquareMeter. All conversions, as defined in the , go via this value. /// - public static MassMomentOfInertiaUnit DefaultBaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; + private static MassMomentOfInertiaUnit DefaultBaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the MassMomentOfInertia quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MassMomentOfInertia", typeof(MassMomentOfInertia).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MassMomentOfInertia. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MassMomentOfInertiaUnit.GramSquareCentimeter, "GramSquareCentimeter", "GramSquareCentimeters", new BaseUnits(length: LengthUnit.Centimeter, mass: MassUnit.Gram)); yield return new (MassMomentOfInertiaUnit.GramSquareDecimeter, "GramSquareDecimeter", "GramSquareDecimeters", new BaseUnits(length: LengthUnit.Decimeter, mass: MassUnit.Gram)); @@ -149,7 +149,7 @@ public static IEnumerable> GetDefaultMap static MassMomentOfInertia() { - Info = MassMomentOfInertiaInfo.CreateDefault(); + Info = MassMomentOfInertiaInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs index aaa5a4c53c..310c251570 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MolalityInfo: QuantityInfo + private static class MolalityInfo { - /// - public MolalityInfo(string name, MolalityUnit baseUnit, IEnumerable> unitMappings, Molality zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Molality.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MolalityInfo(string name, MolalityUnit baseUnit, IEnumerable> unitMappings, Molality zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Molality.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Molality", typeof(Molality).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Molality quantity. - /// - /// A new instance of the class with the default settings. - public static MolalityInfo CreateDefault() - { - return new MolalityInfo(nameof(Molality), DefaultBaseUnit, GetDefaultMappings(), new Molality(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Molality quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MolalityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MolalityInfo(nameof(Molality), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Molality(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MolalityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Molality), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Molality(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [M^-1][N]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, -1, 0, 0, 0, 1, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, -1, 0, 0, 0, 1, 0); /// /// The default base unit of Molality is MolePerKilogram. All conversions, as defined in the , go via this value. /// - public static MolalityUnit DefaultBaseUnit { get; } = MolalityUnit.MolePerKilogram; + private static MolalityUnit DefaultBaseUnit { get; } = MolalityUnit.MolePerKilogram; + + /// + /// The default resource manager for unit abbreviations of the Molality quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Molality", typeof(Molality).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Molality. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MolalityUnit.MillimolePerKilogram, "MillimolePerKilogram", "MillimolesPerKilogram", new BaseUnits(mass: MassUnit.Kilogram, amount: AmountOfSubstanceUnit.Millimole)); yield return new (MolalityUnit.MolePerGram, "MolePerGram", "MolesPerGram", new BaseUnits(mass: MassUnit.Gram, amount: AmountOfSubstanceUnit.Mole)); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefaultMappings() static Molality() { - Info = MolalityInfo.CreateDefault(); + Info = MolalityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 065262517b..0c73878e8d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MolarEnergyInfo: QuantityInfo + private static class MolarEnergyInfo { - /// - public MolarEnergyInfo(string name, MolarEnergyUnit baseUnit, IEnumerable> unitMappings, MolarEnergy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MolarEnergy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MolarEnergyInfo(string name, MolarEnergyUnit baseUnit, IEnumerable> unitMappings, MolarEnergy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MolarEnergy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MolarEnergy", typeof(MolarEnergy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MolarEnergy quantity. - /// - /// A new instance of the class with the default settings. - public static MolarEnergyInfo CreateDefault() - { - return new MolarEnergyInfo(nameof(MolarEnergy), DefaultBaseUnit, GetDefaultMappings(), new MolarEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MolarEnergy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MolarEnergyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MolarEnergyInfo(nameof(MolarEnergy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MolarEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MolarEnergyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MolarEnergy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MolarEnergy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M][N^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, -1, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, -1, 0); /// /// The default base unit of MolarEnergy is JoulePerMole. All conversions, as defined in the , go via this value. /// - public static MolarEnergyUnit DefaultBaseUnit { get; } = MolarEnergyUnit.JoulePerMole; + private static MolarEnergyUnit DefaultBaseUnit { get; } = MolarEnergyUnit.JoulePerMole; + + /// + /// The default resource manager for unit abbreviations of the MolarEnergy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MolarEnergy", typeof(MolarEnergy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MolarEnergy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MolarEnergyUnit.JoulePerMole, "JoulePerMole", "JoulesPerMole", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, amount: AmountOfSubstanceUnit.Mole)); yield return new (MolarEnergyUnit.KilojoulePerMole, "KilojoulePerMole", "KilojoulesPerMole", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, amount: AmountOfSubstanceUnit.Millimole)); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefaultMappings() static MolarEnergy() { - Info = MolarEnergyInfo.CreateDefault(); + Info = MolarEnergyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 69078b6e40..9576663c65 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MolarEntropyInfo: QuantityInfo + private static class MolarEntropyInfo { - /// - public MolarEntropyInfo(string name, MolarEntropyUnit baseUnit, IEnumerable> unitMappings, MolarEntropy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MolarEntropy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MolarEntropyInfo(string name, MolarEntropyUnit baseUnit, IEnumerable> unitMappings, MolarEntropy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MolarEntropy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MolarEntropy", typeof(MolarEntropy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MolarEntropy quantity. - /// - /// A new instance of the class with the default settings. - public static MolarEntropyInfo CreateDefault() - { - return new MolarEntropyInfo(nameof(MolarEntropy), DefaultBaseUnit, GetDefaultMappings(), new MolarEntropy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MolarEntropy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MolarEntropyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MolarEntropyInfo(nameof(MolarEntropy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MolarEntropy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MolarEntropyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MolarEntropy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MolarEntropy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M][Θ^-1][N^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, -1, -1, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, -1, -1, 0); /// /// The default base unit of MolarEntropy is JoulePerMoleKelvin. All conversions, as defined in the , go via this value. /// - public static MolarEntropyUnit DefaultBaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; + private static MolarEntropyUnit DefaultBaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; + + /// + /// The default resource manager for unit abbreviations of the MolarEntropy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MolarEntropy", typeof(MolarEntropy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MolarEntropy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MolarEntropyUnit.JoulePerMoleKelvin, "JoulePerMoleKelvin", "JoulesPerMoleKelvin", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, temperature: TemperatureUnit.Kelvin, amount: AmountOfSubstanceUnit.Mole)); yield return new (MolarEntropyUnit.KilojoulePerMoleKelvin, "KilojoulePerMoleKelvin", "KilojoulesPerMoleKelvin", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, temperature: TemperatureUnit.Kelvin, amount: AmountOfSubstanceUnit.Millimole)); @@ -124,7 +124,7 @@ public static IEnumerable> GetDefaultMappings() static MolarEntropy() { - Info = MolarEntropyInfo.CreateDefault(); + Info = MolarEntropyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index bb53d73fea..737d5cb0bb 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -68,59 +68,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MolarFlowInfo: QuantityInfo + private static class MolarFlowInfo { - /// - public MolarFlowInfo(string name, MolarFlowUnit baseUnit, IEnumerable> unitMappings, MolarFlow zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MolarFlow.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MolarFlowInfo(string name, MolarFlowUnit baseUnit, IEnumerable> unitMappings, MolarFlow zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MolarFlow.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MolarFlow", typeof(MolarFlow).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MolarFlow quantity. - /// - /// A new instance of the class with the default settings. - public static MolarFlowInfo CreateDefault() - { - return new MolarFlowInfo(nameof(MolarFlow), DefaultBaseUnit, GetDefaultMappings(), new MolarFlow(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MolarFlow quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MolarFlowInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MolarFlowInfo(nameof(MolarFlow), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MolarFlow(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MolarFlowInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MolarFlow), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MolarFlow(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][N]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 1, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 1, 0); /// /// The default base unit of MolarFlow is MolePerSecond. All conversions, as defined in the , go via this value. /// - public static MolarFlowUnit DefaultBaseUnit { get; } = MolarFlowUnit.MolePerSecond; + private static MolarFlowUnit DefaultBaseUnit { get; } = MolarFlowUnit.MolePerSecond; + + /// + /// The default resource manager for unit abbreviations of the MolarFlow quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MolarFlow", typeof(MolarFlow).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MolarFlow. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MolarFlowUnit.KilomolePerHour, "KilomolePerHour", "KilomolesPerHour", new BaseUnits(time: DurationUnit.Hour, amount: AmountOfSubstanceUnit.Kilomole)); yield return new (MolarFlowUnit.KilomolePerMinute, "KilomolePerMinute", "KilomolesPerMinute", new BaseUnits(time: DurationUnit.Minute, amount: AmountOfSubstanceUnit.Kilomole)); @@ -136,7 +136,7 @@ public static IEnumerable> GetDefaultMappings() static MolarFlow() { - Info = MolarFlowInfo.CreateDefault(); + Info = MolarFlowInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 1287a2bb9d..d4e6545d4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -67,59 +67,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MolarMassInfo: QuantityInfo + private static class MolarMassInfo { - /// - public MolarMassInfo(string name, MolarMassUnit baseUnit, IEnumerable> unitMappings, MolarMass zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, MolarMass.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MolarMassInfo(string name, MolarMassUnit baseUnit, IEnumerable> unitMappings, MolarMass zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, MolarMass.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.MolarMass", typeof(MolarMass).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the MolarMass quantity. - /// - /// A new instance of the class with the default settings. - public static MolarMassInfo CreateDefault() - { - return new MolarMassInfo(nameof(MolarMass), DefaultBaseUnit, GetDefaultMappings(), new MolarMass(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the MolarMass quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MolarMassInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MolarMassInfo(nameof(MolarMass), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new MolarMass(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MolarMassInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(MolarMass), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new MolarMass(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [M][N^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, 0, 0, 0, -1, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, 0, 0, 0, -1, 0); /// /// The default base unit of MolarMass is KilogramPerMole. All conversions, as defined in the , go via this value. /// - public static MolarMassUnit DefaultBaseUnit { get; } = MolarMassUnit.KilogramPerMole; + private static MolarMassUnit DefaultBaseUnit { get; } = MolarMassUnit.KilogramPerMole; + + /// + /// The default resource manager for unit abbreviations of the MolarMass quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.MolarMass", typeof(MolarMass).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for MolarMass. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MolarMassUnit.CentigramPerMole, "CentigramPerMole", "CentigramsPerMole", new BaseUnits(mass: MassUnit.Centigram, amount: AmountOfSubstanceUnit.Mole)); yield return new (MolarMassUnit.DecagramPerMole, "DecagramPerMole", "DecagramsPerMole", new BaseUnits(mass: MassUnit.Decagram, amount: AmountOfSubstanceUnit.Mole)); @@ -139,7 +139,7 @@ public static IEnumerable> GetDefaultMappings() static MolarMass() { - Info = MolarMassInfo.CreateDefault(); + Info = MolarMassInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index bbf2fcdff0..692d01aeca 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -72,59 +72,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class MolarityInfo: QuantityInfo + private static class MolarityInfo { - /// - public MolarityInfo(string name, MolarityUnit baseUnit, IEnumerable> unitMappings, Molarity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Molarity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public MolarityInfo(string name, MolarityUnit baseUnit, IEnumerable> unitMappings, Molarity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Molarity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Molarity", typeof(Molarity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Molarity quantity. - /// - /// A new instance of the class with the default settings. - public static MolarityInfo CreateDefault() - { - return new MolarityInfo(nameof(Molarity), DefaultBaseUnit, GetDefaultMappings(), new Molarity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Molarity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static MolarityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new MolarityInfo(nameof(Molarity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Molarity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = MolarityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Molarity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Molarity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-3][N]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0); /// /// The default base unit of Molarity is MolePerCubicMeter. All conversions, as defined in the , go via this value. /// - public static MolarityUnit DefaultBaseUnit { get; } = MolarityUnit.MolePerCubicMeter; + private static MolarityUnit DefaultBaseUnit { get; } = MolarityUnit.MolePerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the Molarity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Molarity", typeof(Molarity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Molarity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (MolarityUnit.CentimolePerLiter, "CentimolePerLiter", "CentimolesPerLiter", new BaseUnits(length: LengthUnit.Decimeter, amount: AmountOfSubstanceUnit.Centimole)); yield return new (MolarityUnit.DecimolePerLiter, "DecimolePerLiter", "DecimolesPerLiter", new BaseUnits(length: LengthUnit.Decimeter, amount: AmountOfSubstanceUnit.Decimole)); @@ -142,7 +142,7 @@ public static IEnumerable> GetDefaultMappings() static Molarity() { - Info = MolarityInfo.CreateDefault(); + Info = MolarityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 9171359ff5..3e5f0c3f46 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PermeabilityInfo: QuantityInfo + private static class PermeabilityInfo { - /// - public PermeabilityInfo(string name, PermeabilityUnit baseUnit, IEnumerable> unitMappings, Permeability zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Permeability.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PermeabilityInfo(string name, PermeabilityUnit baseUnit, IEnumerable> unitMappings, Permeability zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Permeability.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Permeability", typeof(Permeability).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Permeability quantity. - /// - /// A new instance of the class with the default settings. - public static PermeabilityInfo CreateDefault() - { - return new PermeabilityInfo(nameof(Permeability), DefaultBaseUnit, GetDefaultMappings(), new Permeability(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Permeability quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PermeabilityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PermeabilityInfo(nameof(Permeability), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Permeability(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PermeabilityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Permeability), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Permeability(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L][M][I^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -2, -2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -2, -2, 0, 0, 0); /// /// The default base unit of Permeability is HenryPerMeter. All conversions, as defined in the , go via this value. /// - public static PermeabilityUnit DefaultBaseUnit { get; } = PermeabilityUnit.HenryPerMeter; + private static PermeabilityUnit DefaultBaseUnit { get; } = PermeabilityUnit.HenryPerMeter; + + /// + /// The default resource manager for unit abbreviations of the Permeability quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Permeability", typeof(Permeability).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Permeability. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PermeabilityUnit.HenryPerMeter, "HenryPerMeter", "HenriesPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings() static Permeability() { - Info = PermeabilityInfo.CreateDefault(); + Info = PermeabilityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 33a28afa33..851012a1c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PermittivityInfo: QuantityInfo + private static class PermittivityInfo { - /// - public PermittivityInfo(string name, PermittivityUnit baseUnit, IEnumerable> unitMappings, Permittivity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Permittivity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PermittivityInfo(string name, PermittivityUnit baseUnit, IEnumerable> unitMappings, Permittivity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Permittivity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Permittivity", typeof(Permittivity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Permittivity quantity. - /// - /// A new instance of the class with the default settings. - public static PermittivityInfo CreateDefault() - { - return new PermittivityInfo(nameof(Permittivity), DefaultBaseUnit, GetDefaultMappings(), new Permittivity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Permittivity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PermittivityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PermittivityInfo(nameof(Permittivity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Permittivity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PermittivityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Permittivity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Permittivity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^4][L^-3][M^-1][I^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, -1, 4, 2, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-3, -1, 4, 2, 0, 0, 0); /// /// The default base unit of Permittivity is FaradPerMeter. All conversions, as defined in the , go via this value. /// - public static PermittivityUnit DefaultBaseUnit { get; } = PermittivityUnit.FaradPerMeter; + private static PermittivityUnit DefaultBaseUnit { get; } = PermittivityUnit.FaradPerMeter; + + /// + /// The default resource manager for unit abbreviations of the Permittivity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Permittivity", typeof(Permittivity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Permittivity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PermittivityUnit.FaradPerMeter, "FaradPerMeter", "FaradsPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings() static Permittivity() { - Info = PermittivityInfo.CreateDefault(); + Info = PermittivityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 5ad1f5db40..11b1768579 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PorousMediumPermeabilityInfo: QuantityInfo + private static class PorousMediumPermeabilityInfo { - /// - public PorousMediumPermeabilityInfo(string name, PorousMediumPermeabilityUnit baseUnit, IEnumerable> unitMappings, PorousMediumPermeability zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, PorousMediumPermeability.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PorousMediumPermeabilityInfo(string name, PorousMediumPermeabilityUnit baseUnit, IEnumerable> unitMappings, PorousMediumPermeability zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, PorousMediumPermeability.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.PorousMediumPermeability", typeof(PorousMediumPermeability).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the PorousMediumPermeability quantity. - /// - /// A new instance of the class with the default settings. - public static PorousMediumPermeabilityInfo CreateDefault() - { - return new PorousMediumPermeabilityInfo(nameof(PorousMediumPermeability), DefaultBaseUnit, GetDefaultMappings(), new PorousMediumPermeability(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the PorousMediumPermeability quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PorousMediumPermeabilityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PorousMediumPermeabilityInfo(nameof(PorousMediumPermeability), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new PorousMediumPermeability(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PorousMediumPermeabilityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(PorousMediumPermeability), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new PorousMediumPermeability(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); /// /// The default base unit of PorousMediumPermeability is SquareMeter. All conversions, as defined in the , go via this value. /// - public static PorousMediumPermeabilityUnit DefaultBaseUnit { get; } = PorousMediumPermeabilityUnit.SquareMeter; + private static PorousMediumPermeabilityUnit DefaultBaseUnit { get; } = PorousMediumPermeabilityUnit.SquareMeter; + + /// + /// The default resource manager for unit abbreviations of the PorousMediumPermeability quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.PorousMediumPermeability", typeof(PorousMediumPermeability).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for PorousMediumPermeability. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PorousMediumPermeabilityUnit.Darcy, "Darcy", "Darcys", BaseUnits.Undefined); yield return new (PorousMediumPermeabilityUnit.Microdarcy, "Microdarcy", "Microdarcys", BaseUnits.Undefined); @@ -129,7 +129,7 @@ public static IEnumerable> GetDefau static PorousMediumPermeability() { - Info = PorousMediumPermeabilityInfo.CreateDefault(); + Info = PorousMediumPermeabilityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index c3f3a2bc66..befdbd125b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -78,59 +78,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PowerInfo: QuantityInfo + private static class PowerInfo { - /// - public PowerInfo(string name, PowerUnit baseUnit, IEnumerable> unitMappings, Power zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Power.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PowerInfo(string name, PowerUnit baseUnit, IEnumerable> unitMappings, Power zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Power.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Power", typeof(Power).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Power quantity. - /// - /// A new instance of the class with the default settings. - public static PowerInfo CreateDefault() - { - return new PowerInfo(nameof(Power), DefaultBaseUnit, GetDefaultMappings(), new Power(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Power quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PowerInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PowerInfo(nameof(Power), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Power(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PowerInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Power), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Power(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); /// /// The default base unit of Power is Watt. All conversions, as defined in the , go via this value. /// - public static PowerUnit DefaultBaseUnit { get; } = PowerUnit.Watt; + private static PowerUnit DefaultBaseUnit { get; } = PowerUnit.Watt; + + /// + /// The default resource manager for unit abbreviations of the Power quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Power", typeof(Power).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Power. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PowerUnit.BoilerHorsepower, "BoilerHorsepower", "BoilerHorsepower", BaseUnits.Undefined); yield return new (PowerUnit.BritishThermalUnitPerHour, "BritishThermalUnitPerHour", "BritishThermalUnitsPerHour", BaseUnits.Undefined); @@ -164,7 +164,7 @@ public static IEnumerable> GetDefaultMappings() static Power() { - Info = PowerInfo.CreateDefault(); + Info = PowerInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index b665c7a743..96e8b7b4fd 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PowerDensityInfo: QuantityInfo + private static class PowerDensityInfo { - /// - public PowerDensityInfo(string name, PowerDensityUnit baseUnit, IEnumerable> unitMappings, PowerDensity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, PowerDensity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PowerDensityInfo(string name, PowerDensityUnit baseUnit, IEnumerable> unitMappings, PowerDensity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, PowerDensity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.PowerDensity", typeof(PowerDensity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the PowerDensity quantity. - /// - /// A new instance of the class with the default settings. - public static PowerDensityInfo CreateDefault() - { - return new PowerDensityInfo(nameof(PowerDensity), DefaultBaseUnit, GetDefaultMappings(), new PowerDensity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the PowerDensity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PowerDensityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PowerDensityInfo(nameof(PowerDensity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new PowerDensity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PowerDensityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(PowerDensity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new PowerDensity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); /// /// The default base unit of PowerDensity is WattPerCubicMeter. All conversions, as defined in the , go via this value. /// - public static PowerDensityUnit DefaultBaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; + private static PowerDensityUnit DefaultBaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the PowerDensity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.PowerDensity", typeof(PowerDensity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for PowerDensity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PowerDensityUnit.DecawattPerCubicFoot, "DecawattPerCubicFoot", "DecawattsPerCubicFoot", BaseUnits.Undefined); yield return new (PowerDensityUnit.DecawattPerCubicInch, "DecawattPerCubicInch", "DecawattsPerCubicInch", BaseUnits.Undefined); @@ -165,7 +165,7 @@ public static IEnumerable> GetDefaultMappings() static PowerDensity() { - Info = PowerDensityInfo.CreateDefault(); + Info = PowerDensityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 56ba172dc7..3bc03b4b32 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PowerRatioInfo: QuantityInfo + private static class PowerRatioInfo { - /// - public PowerRatioInfo(string name, PowerRatioUnit baseUnit, IEnumerable> unitMappings, PowerRatio zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, PowerRatio.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PowerRatioInfo(string name, PowerRatioUnit baseUnit, IEnumerable> unitMappings, PowerRatio zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, PowerRatio.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.PowerRatio", typeof(PowerRatio).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the PowerRatio quantity. - /// - /// A new instance of the class with the default settings. - public static PowerRatioInfo CreateDefault() - { - return new PowerRatioInfo(nameof(PowerRatio), DefaultBaseUnit, GetDefaultMappings(), new PowerRatio(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the PowerRatio quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PowerRatioInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PowerRatioInfo(nameof(PowerRatio), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new PowerRatio(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PowerRatioInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(PowerRatio), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new PowerRatio(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of PowerRatio is DecibelWatt. All conversions, as defined in the , go via this value. /// - public static PowerRatioUnit DefaultBaseUnit { get; } = PowerRatioUnit.DecibelWatt; + private static PowerRatioUnit DefaultBaseUnit { get; } = PowerRatioUnit.DecibelWatt; + + /// + /// The default resource manager for unit abbreviations of the PowerRatio quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.PowerRatio", typeof(PowerRatio).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for PowerRatio. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PowerRatioUnit.DecibelMilliwatt, "DecibelMilliwatt", "DecibelMilliwatts", BaseUnits.Undefined); yield return new (PowerRatioUnit.DecibelWatt, "DecibelWatt", "DecibelWatts", BaseUnits.Undefined); @@ -123,7 +123,7 @@ public static IEnumerable> GetDefaultMappings() static PowerRatio() { - Info = PowerRatioInfo.CreateDefault(); + Info = PowerRatioInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index c903643470..0375f37076 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -74,59 +74,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PressureInfo: QuantityInfo + private static class PressureInfo { - /// - public PressureInfo(string name, PressureUnit baseUnit, IEnumerable> unitMappings, Pressure zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Pressure.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PressureInfo(string name, PressureUnit baseUnit, IEnumerable> unitMappings, Pressure zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Pressure.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Pressure", typeof(Pressure).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Pressure quantity. - /// - /// A new instance of the class with the default settings. - public static PressureInfo CreateDefault() - { - return new PressureInfo(nameof(Pressure), DefaultBaseUnit, GetDefaultMappings(), new Pressure(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Pressure quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PressureInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PressureInfo(nameof(Pressure), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Pressure(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PressureInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Pressure), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Pressure(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); /// /// The default base unit of Pressure is Pascal. All conversions, as defined in the , go via this value. /// - public static PressureUnit DefaultBaseUnit { get; } = PressureUnit.Pascal; + private static PressureUnit DefaultBaseUnit { get; } = PressureUnit.Pascal; + + /// + /// The default resource manager for unit abbreviations of the Pressure quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Pressure", typeof(Pressure).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Pressure. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PressureUnit.Atmosphere, "Atmosphere", "Atmospheres", BaseUnits.Undefined); yield return new (PressureUnit.Bar, "Bar", "Bars", BaseUnits.Undefined); @@ -180,7 +180,7 @@ public static IEnumerable> GetDefaultMappings() static Pressure() { - Info = PressureInfo.CreateDefault(); + Info = PressureInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 60407c405d..d291481b64 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class PressureChangeRateInfo: QuantityInfo + private static class PressureChangeRateInfo { - /// - public PressureChangeRateInfo(string name, PressureChangeRateUnit baseUnit, IEnumerable> unitMappings, PressureChangeRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, PressureChangeRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public PressureChangeRateInfo(string name, PressureChangeRateUnit baseUnit, IEnumerable> unitMappings, PressureChangeRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, PressureChangeRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.PressureChangeRate", typeof(PressureChangeRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the PressureChangeRate quantity. - /// - /// A new instance of the class with the default settings. - public static PressureChangeRateInfo CreateDefault() - { - return new PressureChangeRateInfo(nameof(PressureChangeRate), DefaultBaseUnit, GetDefaultMappings(), new PressureChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the PressureChangeRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static PressureChangeRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new PressureChangeRateInfo(nameof(PressureChangeRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new PressureChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = PressureChangeRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(PressureChangeRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new PressureChangeRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); /// /// The default base unit of PressureChangeRate is PascalPerSecond. All conversions, as defined in the , go via this value. /// - public static PressureChangeRateUnit DefaultBaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; + private static PressureChangeRateUnit DefaultBaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; + + /// + /// The default resource manager for unit abbreviations of the PressureChangeRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.PressureChangeRate", typeof(PressureChangeRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for PressureChangeRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (PressureChangeRateUnit.AtmospherePerSecond, "AtmospherePerSecond", "AtmospheresPerSecond", BaseUnits.Undefined); yield return new (PressureChangeRateUnit.BarPerMinute, "BarPerMinute", "BarsPerMinute", BaseUnits.Undefined); @@ -142,7 +142,7 @@ public static IEnumerable> GetDefaultMapp static PressureChangeRate() { - Info = PressureChangeRateInfo.CreateDefault(); + Info = PressureChangeRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs index 2d8d6f9c15..b07f01153d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -66,59 +66,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RadiationEquivalentDoseInfo: QuantityInfo + private static class RadiationEquivalentDoseInfo { - /// - public RadiationEquivalentDoseInfo(string name, RadiationEquivalentDoseUnit baseUnit, IEnumerable> unitMappings, RadiationEquivalentDose zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RadiationEquivalentDose.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RadiationEquivalentDoseInfo(string name, RadiationEquivalentDoseUnit baseUnit, IEnumerable> unitMappings, RadiationEquivalentDose zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RadiationEquivalentDose.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RadiationEquivalentDose", typeof(RadiationEquivalentDose).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RadiationEquivalentDose quantity. - /// - /// A new instance of the class with the default settings. - public static RadiationEquivalentDoseInfo CreateDefault() - { - return new RadiationEquivalentDoseInfo(nameof(RadiationEquivalentDose), DefaultBaseUnit, GetDefaultMappings(), new RadiationEquivalentDose(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RadiationEquivalentDose quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RadiationEquivalentDoseInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RadiationEquivalentDoseInfo(nameof(RadiationEquivalentDose), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RadiationEquivalentDose(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RadiationEquivalentDoseInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RadiationEquivalentDose), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RadiationEquivalentDose(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); /// /// The default base unit of RadiationEquivalentDose is Sievert. All conversions, as defined in the , go via this value. /// - public static RadiationEquivalentDoseUnit DefaultBaseUnit { get; } = RadiationEquivalentDoseUnit.Sievert; + private static RadiationEquivalentDoseUnit DefaultBaseUnit { get; } = RadiationEquivalentDoseUnit.Sievert; + + /// + /// The default resource manager for unit abbreviations of the RadiationEquivalentDose quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RadiationEquivalentDose", typeof(RadiationEquivalentDose).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RadiationEquivalentDose. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RadiationEquivalentDoseUnit.Microsievert, "Microsievert", "Microsieverts", new BaseUnits(length: LengthUnit.Millimeter, time: DurationUnit.Second)); yield return new (RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, "MilliroentgenEquivalentMan", "MilliroentgensEquivalentMan", BaseUnits.Undefined); @@ -131,7 +131,7 @@ public static IEnumerable> GetDefaul static RadiationEquivalentDose() { - Info = RadiationEquivalentDoseInfo.CreateDefault(); + Info = RadiationEquivalentDoseInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index 02f3899845..21a101e8f3 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RadiationEquivalentDoseRateInfo: QuantityInfo + private static class RadiationEquivalentDoseRateInfo { - /// - public RadiationEquivalentDoseRateInfo(string name, RadiationEquivalentDoseRateUnit baseUnit, IEnumerable> unitMappings, RadiationEquivalentDoseRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RadiationEquivalentDoseRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RadiationEquivalentDoseRateInfo(string name, RadiationEquivalentDoseRateUnit baseUnit, IEnumerable> unitMappings, RadiationEquivalentDoseRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RadiationEquivalentDoseRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RadiationEquivalentDoseRate", typeof(RadiationEquivalentDoseRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RadiationEquivalentDoseRate quantity. - /// - /// A new instance of the class with the default settings. - public static RadiationEquivalentDoseRateInfo CreateDefault() - { - return new RadiationEquivalentDoseRateInfo(nameof(RadiationEquivalentDoseRate), DefaultBaseUnit, GetDefaultMappings(), new RadiationEquivalentDoseRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RadiationEquivalentDoseRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RadiationEquivalentDoseRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RadiationEquivalentDoseRateInfo(nameof(RadiationEquivalentDoseRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RadiationEquivalentDoseRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RadiationEquivalentDoseRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RadiationEquivalentDoseRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RadiationEquivalentDoseRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -3, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -3, 0, 0, 0, 0); /// /// The default base unit of RadiationEquivalentDoseRate is SievertPerSecond. All conversions, as defined in the , go via this value. /// - public static RadiationEquivalentDoseRateUnit DefaultBaseUnit { get; } = RadiationEquivalentDoseRateUnit.SievertPerSecond; + private static RadiationEquivalentDoseRateUnit DefaultBaseUnit { get; } = RadiationEquivalentDoseRateUnit.SievertPerSecond; + + /// + /// The default resource manager for unit abbreviations of the RadiationEquivalentDoseRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RadiationEquivalentDoseRate", typeof(RadiationEquivalentDoseRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RadiationEquivalentDoseRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RadiationEquivalentDoseRateUnit.MicrosievertPerHour, "MicrosievertPerHour", "MicrosievertsPerHour", BaseUnits.Undefined); yield return new (RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, "MicrosievertPerSecond", "MicrosievertsPerSecond", new BaseUnits(length: LengthUnit.Millimeter, time: DurationUnit.Second)); @@ -134,7 +134,7 @@ public static IEnumerable> GetDe static RadiationEquivalentDoseRate() { - Info = RadiationEquivalentDoseRateInfo.CreateDefault(); + Info = RadiationEquivalentDoseRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs index e29d6d67ad..63b349c697 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RadiationExposureInfo: QuantityInfo + private static class RadiationExposureInfo { - /// - public RadiationExposureInfo(string name, RadiationExposureUnit baseUnit, IEnumerable> unitMappings, RadiationExposure zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RadiationExposure.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RadiationExposureInfo(string name, RadiationExposureUnit baseUnit, IEnumerable> unitMappings, RadiationExposure zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RadiationExposure.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RadiationExposure", typeof(RadiationExposure).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RadiationExposure quantity. - /// - /// A new instance of the class with the default settings. - public static RadiationExposureInfo CreateDefault() - { - return new RadiationExposureInfo(nameof(RadiationExposure), DefaultBaseUnit, GetDefaultMappings(), new RadiationExposure(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RadiationExposure quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RadiationExposureInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RadiationExposureInfo(nameof(RadiationExposure), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RadiationExposure(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RadiationExposureInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RadiationExposure), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RadiationExposure(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T][M^-1][I]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, -1, 1, 1, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, -1, 1, 1, 0, 0, 0); /// /// The default base unit of RadiationExposure is CoulombPerKilogram. All conversions, as defined in the , go via this value. /// - public static RadiationExposureUnit DefaultBaseUnit { get; } = RadiationExposureUnit.CoulombPerKilogram; + private static RadiationExposureUnit DefaultBaseUnit { get; } = RadiationExposureUnit.CoulombPerKilogram; + + /// + /// The default resource manager for unit abbreviations of the RadiationExposure quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RadiationExposure", typeof(RadiationExposure).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RadiationExposure. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RadiationExposureUnit.CoulombPerKilogram, "CoulombPerKilogram", "CoulombsPerKilogram", new BaseUnits(mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)); yield return new (RadiationExposureUnit.MicrocoulombPerKilogram, "MicrocoulombPerKilogram", "MicrocoulombsPerKilogram", new BaseUnits(mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Microampere)); @@ -129,7 +129,7 @@ public static IEnumerable> GetDefaultMappi static RadiationExposure() { - Info = RadiationExposureInfo.CreateDefault(); + Info = RadiationExposureInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs index bcd0021fb7..7296f3c27a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RadioactivityInfo: QuantityInfo + private static class RadioactivityInfo { - /// - public RadioactivityInfo(string name, RadioactivityUnit baseUnit, IEnumerable> unitMappings, Radioactivity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Radioactivity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RadioactivityInfo(string name, RadioactivityUnit baseUnit, IEnumerable> unitMappings, Radioactivity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Radioactivity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Radioactivity", typeof(Radioactivity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Radioactivity quantity. - /// - /// A new instance of the class with the default settings. - public static RadioactivityInfo CreateDefault() - { - return new RadioactivityInfo(nameof(Radioactivity), DefaultBaseUnit, GetDefaultMappings(), new Radioactivity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Radioactivity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RadioactivityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RadioactivityInfo(nameof(Radioactivity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Radioactivity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RadioactivityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Radioactivity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Radioactivity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); /// /// The default base unit of Radioactivity is Becquerel. All conversions, as defined in the , go via this value. /// - public static RadioactivityUnit DefaultBaseUnit { get; } = RadioactivityUnit.Becquerel; + private static RadioactivityUnit DefaultBaseUnit { get; } = RadioactivityUnit.Becquerel; + + /// + /// The default resource manager for unit abbreviations of the Radioactivity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Radioactivity", typeof(Radioactivity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Radioactivity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RadioactivityUnit.Becquerel, "Becquerel", "Becquerels", new BaseUnits(time: DurationUnit.Second)); yield return new (RadioactivityUnit.Curie, "Curie", "Curies", new BaseUnits(time: DurationUnit.Second)); @@ -150,7 +150,7 @@ public static IEnumerable> GetDefaultMappings( static Radioactivity() { - Info = RadioactivityInfo.CreateDefault(); + Info = RadioactivityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 07427f7b80..ae5928136b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RatioInfo: QuantityInfo + private static class RatioInfo { - /// - public RatioInfo(string name, RatioUnit baseUnit, IEnumerable> unitMappings, Ratio zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Ratio.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RatioInfo(string name, RatioUnit baseUnit, IEnumerable> unitMappings, Ratio zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Ratio.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Ratio", typeof(Ratio).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Ratio quantity. - /// - /// A new instance of the class with the default settings. - public static RatioInfo CreateDefault() - { - return new RatioInfo(nameof(Ratio), DefaultBaseUnit, GetDefaultMappings(), new Ratio(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Ratio quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RatioInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RatioInfo(nameof(Ratio), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Ratio(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RatioInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Ratio), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Ratio(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of Ratio is DecimalFraction. All conversions, as defined in the , go via this value. /// - public static RatioUnit DefaultBaseUnit { get; } = RatioUnit.DecimalFraction; + private static RatioUnit DefaultBaseUnit { get; } = RatioUnit.DecimalFraction; + + /// + /// The default resource manager for unit abbreviations of the Ratio quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Ratio", typeof(Ratio).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Ratio. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RatioUnit.DecimalFraction, "DecimalFraction", "DecimalFractions", BaseUnits.Undefined); yield return new (RatioUnit.PartPerBillion, "PartPerBillion", "PartsPerBillion", BaseUnits.Undefined); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefaultMappings() static Ratio() { - Info = RatioInfo.CreateDefault(); + Info = RatioInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index ac6fab6bb9..d00b960fc2 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RatioChangeRateInfo: QuantityInfo + private static class RatioChangeRateInfo { - /// - public RatioChangeRateInfo(string name, RatioChangeRateUnit baseUnit, IEnumerable> unitMappings, RatioChangeRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RatioChangeRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RatioChangeRateInfo(string name, RatioChangeRateUnit baseUnit, IEnumerable> unitMappings, RatioChangeRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RatioChangeRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RatioChangeRate", typeof(RatioChangeRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RatioChangeRate quantity. - /// - /// A new instance of the class with the default settings. - public static RatioChangeRateInfo CreateDefault() - { - return new RatioChangeRateInfo(nameof(RatioChangeRate), DefaultBaseUnit, GetDefaultMappings(), new RatioChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RatioChangeRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RatioChangeRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RatioChangeRateInfo(nameof(RatioChangeRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RatioChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RatioChangeRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RatioChangeRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RatioChangeRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); /// /// The default base unit of RatioChangeRate is DecimalFractionPerSecond. All conversions, as defined in the , go via this value. /// - public static RatioChangeRateUnit DefaultBaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; + private static RatioChangeRateUnit DefaultBaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; + + /// + /// The default resource manager for unit abbreviations of the RatioChangeRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RatioChangeRate", typeof(RatioChangeRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RatioChangeRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RatioChangeRateUnit.DecimalFractionPerSecond, "DecimalFractionPerSecond", "DecimalFractionsPerSecond", new BaseUnits(time: DurationUnit.Second)); yield return new (RatioChangeRateUnit.PercentPerSecond, "PercentPerSecond", "PercentsPerSecond", BaseUnits.Undefined); @@ -123,7 +123,7 @@ public static IEnumerable> GetDefaultMapping static RatioChangeRate() { - Info = RatioChangeRateInfo.CreateDefault(); + Info = RatioChangeRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 9225e3c436..1b6f351870 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -72,59 +72,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ReciprocalAreaInfo: QuantityInfo + private static class ReciprocalAreaInfo { - /// - public ReciprocalAreaInfo(string name, ReciprocalAreaUnit baseUnit, IEnumerable> unitMappings, ReciprocalArea zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ReciprocalArea.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ReciprocalAreaInfo(string name, ReciprocalAreaUnit baseUnit, IEnumerable> unitMappings, ReciprocalArea zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ReciprocalArea.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ReciprocalArea", typeof(ReciprocalArea).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ReciprocalArea quantity. - /// - /// A new instance of the class with the default settings. - public static ReciprocalAreaInfo CreateDefault() - { - return new ReciprocalAreaInfo(nameof(ReciprocalArea), DefaultBaseUnit, GetDefaultMappings(), new ReciprocalArea(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ReciprocalArea quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ReciprocalAreaInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ReciprocalAreaInfo(nameof(ReciprocalArea), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ReciprocalArea(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ReciprocalAreaInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ReciprocalArea), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ReciprocalArea(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 0, 0, 0, 0, 0, 0); /// /// The default base unit of ReciprocalArea is InverseSquareMeter. All conversions, as defined in the , go via this value. /// - public static ReciprocalAreaUnit DefaultBaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; + private static ReciprocalAreaUnit DefaultBaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the ReciprocalArea quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ReciprocalArea", typeof(ReciprocalArea).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ReciprocalArea. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ReciprocalAreaUnit.InverseSquareCentimeter, "InverseSquareCentimeter", "InverseSquareCentimeters", new BaseUnits(length: LengthUnit.Centimeter)); yield return new (ReciprocalAreaUnit.InverseSquareDecimeter, "InverseSquareDecimeter", "InverseSquareDecimeters", new BaseUnits(length: LengthUnit.Decimeter)); @@ -142,7 +142,7 @@ public static IEnumerable> GetDefaultMappings static ReciprocalArea() { - Info = ReciprocalAreaInfo.CreateDefault(); + Info = ReciprocalAreaInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index d5a471d2a0..8d202b0143 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -74,59 +74,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ReciprocalLengthInfo: QuantityInfo + private static class ReciprocalLengthInfo { - /// - public ReciprocalLengthInfo(string name, ReciprocalLengthUnit baseUnit, IEnumerable> unitMappings, ReciprocalLength zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ReciprocalLength.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ReciprocalLengthInfo(string name, ReciprocalLengthUnit baseUnit, IEnumerable> unitMappings, ReciprocalLength zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ReciprocalLength.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ReciprocalLength", typeof(ReciprocalLength).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ReciprocalLength quantity. - /// - /// A new instance of the class with the default settings. - public static ReciprocalLengthInfo CreateDefault() - { - return new ReciprocalLengthInfo(nameof(ReciprocalLength), DefaultBaseUnit, GetDefaultMappings(), new ReciprocalLength(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ReciprocalLength quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ReciprocalLengthInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ReciprocalLengthInfo(nameof(ReciprocalLength), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ReciprocalLength(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ReciprocalLengthInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ReciprocalLength), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ReciprocalLength(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 0, 0, 0, 0, 0); /// /// The default base unit of ReciprocalLength is InverseMeter. All conversions, as defined in the , go via this value. /// - public static ReciprocalLengthUnit DefaultBaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; + private static ReciprocalLengthUnit DefaultBaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; + + /// + /// The default resource manager for unit abbreviations of the ReciprocalLength quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ReciprocalLength", typeof(ReciprocalLength).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ReciprocalLength. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ReciprocalLengthUnit.InverseCentimeter, "InverseCentimeter", "InverseCentimeters", new BaseUnits(length: LengthUnit.Centimeter)); yield return new (ReciprocalLengthUnit.InverseFoot, "InverseFoot", "InverseFeet", new BaseUnits(length: LengthUnit.Foot)); @@ -143,7 +143,7 @@ public static IEnumerable> GetDefaultMappin static ReciprocalLength() { - Info = ReciprocalLengthInfo.CreateDefault(); + Info = ReciprocalLengthInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index b4325f7318..b17431136a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RelativeHumidityInfo: QuantityInfo + private static class RelativeHumidityInfo { - /// - public RelativeHumidityInfo(string name, RelativeHumidityUnit baseUnit, IEnumerable> unitMappings, RelativeHumidity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RelativeHumidity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RelativeHumidityInfo(string name, RelativeHumidityUnit baseUnit, IEnumerable> unitMappings, RelativeHumidity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RelativeHumidity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RelativeHumidity", typeof(RelativeHumidity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RelativeHumidity quantity. - /// - /// A new instance of the class with the default settings. - public static RelativeHumidityInfo CreateDefault() - { - return new RelativeHumidityInfo(nameof(RelativeHumidity), DefaultBaseUnit, GetDefaultMappings(), new RelativeHumidity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RelativeHumidity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RelativeHumidityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RelativeHumidityInfo(nameof(RelativeHumidity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RelativeHumidity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RelativeHumidityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RelativeHumidity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RelativeHumidity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of RelativeHumidity is Percent. All conversions, as defined in the , go via this value. /// - public static RelativeHumidityUnit DefaultBaseUnit { get; } = RelativeHumidityUnit.Percent; + private static RelativeHumidityUnit DefaultBaseUnit { get; } = RelativeHumidityUnit.Percent; + + /// + /// The default resource manager for unit abbreviations of the RelativeHumidity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RelativeHumidity", typeof(RelativeHumidity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RelativeHumidity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RelativeHumidityUnit.Percent, "Percent", "Percent", BaseUnits.Undefined); } @@ -122,7 +122,7 @@ public static IEnumerable> GetDefaultMappin static RelativeHumidity() { - Info = RelativeHumidityInfo.CreateDefault(); + Info = RelativeHumidityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 80bf1c955b..11159dd6fb 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RotationalAccelerationInfo: QuantityInfo + private static class RotationalAccelerationInfo { - /// - public RotationalAccelerationInfo(string name, RotationalAccelerationUnit baseUnit, IEnumerable> unitMappings, RotationalAcceleration zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RotationalAcceleration.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RotationalAccelerationInfo(string name, RotationalAccelerationUnit baseUnit, IEnumerable> unitMappings, RotationalAcceleration zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RotationalAcceleration.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RotationalAcceleration", typeof(RotationalAcceleration).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RotationalAcceleration quantity. - /// - /// A new instance of the class with the default settings. - public static RotationalAccelerationInfo CreateDefault() - { - return new RotationalAccelerationInfo(nameof(RotationalAcceleration), DefaultBaseUnit, GetDefaultMappings(), new RotationalAcceleration(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RotationalAcceleration quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RotationalAccelerationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RotationalAccelerationInfo(nameof(RotationalAcceleration), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RotationalAcceleration(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RotationalAccelerationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RotationalAcceleration), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RotationalAcceleration(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -2, 0, 0, 0, 0); /// /// The default base unit of RotationalAcceleration is RadianPerSecondSquared. All conversions, as defined in the , go via this value. /// - public static RotationalAccelerationUnit DefaultBaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; + private static RotationalAccelerationUnit DefaultBaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; + + /// + /// The default resource manager for unit abbreviations of the RotationalAcceleration quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RotationalAcceleration", typeof(RotationalAcceleration).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RotationalAcceleration. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RotationalAccelerationUnit.DegreePerSecondSquared, "DegreePerSecondSquared", "DegreesPerSecondSquared", BaseUnits.Undefined); yield return new (RotationalAccelerationUnit.RadianPerSecondSquared, "RadianPerSecondSquared", "RadiansPerSecondSquared", new BaseUnits(time: DurationUnit.Second)); @@ -125,7 +125,7 @@ public static IEnumerable> GetDefault static RotationalAcceleration() { - Info = RotationalAccelerationInfo.CreateDefault(); + Info = RotationalAccelerationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index ee045bd62c..9c8920fb5a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -66,59 +66,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RotationalSpeedInfo: QuantityInfo + private static class RotationalSpeedInfo { - /// - public RotationalSpeedInfo(string name, RotationalSpeedUnit baseUnit, IEnumerable> unitMappings, RotationalSpeed zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RotationalSpeed.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RotationalSpeedInfo(string name, RotationalSpeedUnit baseUnit, IEnumerable> unitMappings, RotationalSpeed zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RotationalSpeed.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RotationalSpeed", typeof(RotationalSpeed).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RotationalSpeed quantity. - /// - /// A new instance of the class with the default settings. - public static RotationalSpeedInfo CreateDefault() - { - return new RotationalSpeedInfo(nameof(RotationalSpeed), DefaultBaseUnit, GetDefaultMappings(), new RotationalSpeed(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RotationalSpeed quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RotationalSpeedInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RotationalSpeedInfo(nameof(RotationalSpeed), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RotationalSpeed(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RotationalSpeedInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RotationalSpeed), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RotationalSpeed(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); /// /// The default base unit of RotationalSpeed is RadianPerSecond. All conversions, as defined in the , go via this value. /// - public static RotationalSpeedUnit DefaultBaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; + private static RotationalSpeedUnit DefaultBaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; + + /// + /// The default resource manager for unit abbreviations of the RotationalSpeed quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RotationalSpeed", typeof(RotationalSpeed).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RotationalSpeed. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RotationalSpeedUnit.CentiradianPerSecond, "CentiradianPerSecond", "CentiradiansPerSecond", BaseUnits.Undefined); yield return new (RotationalSpeedUnit.DeciradianPerSecond, "DeciradianPerSecond", "DeciradiansPerSecond", BaseUnits.Undefined); @@ -138,7 +138,7 @@ public static IEnumerable> GetDefaultMapping static RotationalSpeed() { - Info = RotationalSpeedInfo.CreateDefault(); + Info = RotationalSpeedInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 48a35f8fb2..39613d47f4 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -67,59 +67,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RotationalStiffnessInfo: QuantityInfo + private static class RotationalStiffnessInfo { - /// - public RotationalStiffnessInfo(string name, RotationalStiffnessUnit baseUnit, IEnumerable> unitMappings, RotationalStiffness zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RotationalStiffness.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RotationalStiffnessInfo(string name, RotationalStiffnessUnit baseUnit, IEnumerable> unitMappings, RotationalStiffness zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RotationalStiffness.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RotationalStiffness", typeof(RotationalStiffness).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RotationalStiffness quantity. - /// - /// A new instance of the class with the default settings. - public static RotationalStiffnessInfo CreateDefault() - { - return new RotationalStiffnessInfo(nameof(RotationalStiffness), DefaultBaseUnit, GetDefaultMappings(), new RotationalStiffness(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RotationalStiffness quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RotationalStiffnessInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RotationalStiffnessInfo(nameof(RotationalStiffness), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RotationalStiffness(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RotationalStiffnessInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RotationalStiffness), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RotationalStiffness(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); /// /// The default base unit of RotationalStiffness is NewtonMeterPerRadian. All conversions, as defined in the , go via this value. /// - public static RotationalStiffnessUnit DefaultBaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; + private static RotationalStiffnessUnit DefaultBaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; + + /// + /// The default resource manager for unit abbreviations of the RotationalStiffness quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RotationalStiffness", typeof(RotationalStiffness).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RotationalStiffness. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RotationalStiffnessUnit.CentinewtonMeterPerDegree, "CentinewtonMeterPerDegree", "CentinewtonMetersPerDegree", BaseUnits.Undefined); yield return new (RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, "CentinewtonMillimeterPerDegree", "CentinewtonMillimetersPerDegree", BaseUnits.Undefined); @@ -159,7 +159,7 @@ public static IEnumerable> GetDefaultMap static RotationalStiffness() { - Info = RotationalStiffnessInfo.CreateDefault(); + Info = RotationalStiffnessInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index c8b9d39607..5d3afa7508 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class RotationalStiffnessPerLengthInfo: QuantityInfo + private static class RotationalStiffnessPerLengthInfo { - /// - public RotationalStiffnessPerLengthInfo(string name, RotationalStiffnessPerLengthUnit baseUnit, IEnumerable> unitMappings, RotationalStiffnessPerLength zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, RotationalStiffnessPerLength.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public RotationalStiffnessPerLengthInfo(string name, RotationalStiffnessPerLengthUnit baseUnit, IEnumerable> unitMappings, RotationalStiffnessPerLength zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, RotationalStiffnessPerLength.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.RotationalStiffnessPerLength", typeof(RotationalStiffnessPerLength).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the RotationalStiffnessPerLength quantity. - /// - /// A new instance of the class with the default settings. - public static RotationalStiffnessPerLengthInfo CreateDefault() - { - return new RotationalStiffnessPerLengthInfo(nameof(RotationalStiffnessPerLength), DefaultBaseUnit, GetDefaultMappings(), new RotationalStiffnessPerLength(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the RotationalStiffnessPerLength quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static RotationalStiffnessPerLengthInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new RotationalStiffnessPerLengthInfo(nameof(RotationalStiffnessPerLength), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new RotationalStiffnessPerLength(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = RotationalStiffnessPerLengthInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(RotationalStiffnessPerLength), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new RotationalStiffnessPerLength(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); /// /// The default base unit of RotationalStiffnessPerLength is NewtonMeterPerRadianPerMeter. All conversions, as defined in the , go via this value. /// - public static RotationalStiffnessPerLengthUnit DefaultBaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; + private static RotationalStiffnessPerLengthUnit DefaultBaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; + + /// + /// The default resource manager for unit abbreviations of the RotationalStiffnessPerLength quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.RotationalStiffnessPerLength", typeof(RotationalStiffnessPerLength).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for RotationalStiffnessPerLength. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, "KilonewtonMeterPerRadianPerMeter", "KilonewtonMetersPerRadianPerMeter", new BaseUnits(length: LengthUnit.Kilometer, mass: MassUnit.Kilogram, time: DurationUnit.Second)); yield return new (RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, "KilopoundForceFootPerDegreesPerFoot", "KilopoundForceFeetPerDegreesPerFeet", BaseUnits.Undefined); @@ -129,7 +129,7 @@ public static IEnumerable> GetD static RotationalStiffnessPerLength() { - Info = RotationalStiffnessPerLengthInfo.CreateDefault(); + Info = RotationalStiffnessPerLengthInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 9bd042b2c8..adf7a51698 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ScalarInfo: QuantityInfo + private static class ScalarInfo { - /// - public ScalarInfo(string name, ScalarUnit baseUnit, IEnumerable> unitMappings, Scalar zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Scalar.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ScalarInfo(string name, ScalarUnit baseUnit, IEnumerable> unitMappings, Scalar zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Scalar.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Scalar", typeof(Scalar).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Scalar quantity. - /// - /// A new instance of the class with the default settings. - public static ScalarInfo CreateDefault() - { - return new ScalarInfo(nameof(Scalar), DefaultBaseUnit, GetDefaultMappings(), new Scalar(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Scalar quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ScalarInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ScalarInfo(nameof(Scalar), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Scalar(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ScalarInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Scalar), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Scalar(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of Scalar is Amount. All conversions, as defined in the , go via this value. /// - public static ScalarUnit DefaultBaseUnit { get; } = ScalarUnit.Amount; + private static ScalarUnit DefaultBaseUnit { get; } = ScalarUnit.Amount; + + /// + /// The default resource manager for unit abbreviations of the Scalar quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Scalar", typeof(Scalar).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Scalar. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ScalarUnit.Amount, "Amount", "Amount", BaseUnits.Undefined); } @@ -122,7 +122,7 @@ public static IEnumerable> GetDefaultMappings() static Scalar() { - Info = ScalarInfo.CreateDefault(); + Info = ScalarInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 7d7bb376cb..f9f1fcff21 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class SolidAngleInfo: QuantityInfo + private static class SolidAngleInfo { - /// - public SolidAngleInfo(string name, SolidAngleUnit baseUnit, IEnumerable> unitMappings, SolidAngle zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, SolidAngle.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public SolidAngleInfo(string name, SolidAngleUnit baseUnit, IEnumerable> unitMappings, SolidAngle zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, SolidAngle.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.SolidAngle", typeof(SolidAngle).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the SolidAngle quantity. - /// - /// A new instance of the class with the default settings. - public static SolidAngleInfo CreateDefault() - { - return new SolidAngleInfo(nameof(SolidAngle), DefaultBaseUnit, GetDefaultMappings(), new SolidAngle(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the SolidAngle quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static SolidAngleInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new SolidAngleInfo(nameof(SolidAngle), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new SolidAngle(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = SolidAngleInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(SolidAngle), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new SolidAngle(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of SolidAngle is Steradian. All conversions, as defined in the , go via this value. /// - public static SolidAngleUnit DefaultBaseUnit { get; } = SolidAngleUnit.Steradian; + private static SolidAngleUnit DefaultBaseUnit { get; } = SolidAngleUnit.Steradian; + + /// + /// The default resource manager for unit abbreviations of the SolidAngle quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.SolidAngle", typeof(SolidAngle).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for SolidAngle. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (SolidAngleUnit.Steradian, "Steradian", "Steradians", BaseUnits.Undefined); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings() static SolidAngle() { - Info = SolidAngleInfo.CreateDefault(); + Info = SolidAngleInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 9efecb25ab..8bfd8b7dcb 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -73,59 +73,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class SpecificEnergyInfo: QuantityInfo + private static class SpecificEnergyInfo { - /// - public SpecificEnergyInfo(string name, SpecificEnergyUnit baseUnit, IEnumerable> unitMappings, SpecificEnergy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, SpecificEnergy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public SpecificEnergyInfo(string name, SpecificEnergyUnit baseUnit, IEnumerable> unitMappings, SpecificEnergy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, SpecificEnergy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.SpecificEnergy", typeof(SpecificEnergy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the SpecificEnergy quantity. - /// - /// A new instance of the class with the default settings. - public static SpecificEnergyInfo CreateDefault() - { - return new SpecificEnergyInfo(nameof(SpecificEnergy), DefaultBaseUnit, GetDefaultMappings(), new SpecificEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the SpecificEnergy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static SpecificEnergyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new SpecificEnergyInfo(nameof(SpecificEnergy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new SpecificEnergy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = SpecificEnergyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(SpecificEnergy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new SpecificEnergy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); /// /// The default base unit of SpecificEnergy is JoulePerKilogram. All conversions, as defined in the , go via this value. /// - public static SpecificEnergyUnit DefaultBaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; + private static SpecificEnergyUnit DefaultBaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; + + /// + /// The default resource manager for unit abbreviations of the SpecificEnergy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.SpecificEnergy", typeof(SpecificEnergy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for SpecificEnergy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (SpecificEnergyUnit.BtuPerPound, "BtuPerPound", "BtuPerPound", BaseUnits.Undefined); yield return new (SpecificEnergyUnit.CaloriePerGram, "CaloriePerGram", "CaloriesPerGram", BaseUnits.Undefined); @@ -162,7 +162,7 @@ public static IEnumerable> GetDefaultMappings static SpecificEnergy() { - Info = SpecificEnergyInfo.CreateDefault(); + Info = SpecificEnergyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index f257600106..9c468986d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -66,59 +66,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class SpecificEntropyInfo: QuantityInfo + private static class SpecificEntropyInfo { - /// - public SpecificEntropyInfo(string name, SpecificEntropyUnit baseUnit, IEnumerable> unitMappings, SpecificEntropy zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, SpecificEntropy.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public SpecificEntropyInfo(string name, SpecificEntropyUnit baseUnit, IEnumerable> unitMappings, SpecificEntropy zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, SpecificEntropy.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.SpecificEntropy", typeof(SpecificEntropy).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the SpecificEntropy quantity. - /// - /// A new instance of the class with the default settings. - public static SpecificEntropyInfo CreateDefault() - { - return new SpecificEntropyInfo(nameof(SpecificEntropy), DefaultBaseUnit, GetDefaultMappings(), new SpecificEntropy(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the SpecificEntropy quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static SpecificEntropyInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new SpecificEntropyInfo(nameof(SpecificEntropy), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new SpecificEntropy(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = SpecificEntropyInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(SpecificEntropy), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new SpecificEntropy(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][Θ^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, -1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, -2, 0, -1, 0, 0); /// /// The default base unit of SpecificEntropy is JoulePerKilogramKelvin. All conversions, as defined in the , go via this value. /// - public static SpecificEntropyUnit DefaultBaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; + private static SpecificEntropyUnit DefaultBaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; + + /// + /// The default resource manager for unit abbreviations of the SpecificEntropy quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.SpecificEntropy", typeof(SpecificEntropy).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for SpecificEntropy. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (SpecificEntropyUnit.BtuPerPoundFahrenheit, "BtuPerPoundFahrenheit", "BtusPerPoundFahrenheit", BaseUnits.Undefined); yield return new (SpecificEntropyUnit.CaloriePerGramKelvin, "CaloriePerGramKelvin", "CaloriesPerGramKelvin", BaseUnits.Undefined); @@ -134,7 +134,7 @@ public static IEnumerable> GetDefaultMapping static SpecificEntropy() { - Info = SpecificEntropyInfo.CreateDefault(); + Info = SpecificEntropyInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index a2f9b67a9d..7d4cd4e9ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class SpecificFuelConsumptionInfo: QuantityInfo + private static class SpecificFuelConsumptionInfo { - /// - public SpecificFuelConsumptionInfo(string name, SpecificFuelConsumptionUnit baseUnit, IEnumerable> unitMappings, SpecificFuelConsumption zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, SpecificFuelConsumption.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public SpecificFuelConsumptionInfo(string name, SpecificFuelConsumptionUnit baseUnit, IEnumerable> unitMappings, SpecificFuelConsumption zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, SpecificFuelConsumption.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.SpecificFuelConsumption", typeof(SpecificFuelConsumption).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the SpecificFuelConsumption quantity. - /// - /// A new instance of the class with the default settings. - public static SpecificFuelConsumptionInfo CreateDefault() - { - return new SpecificFuelConsumptionInfo(nameof(SpecificFuelConsumption), DefaultBaseUnit, GetDefaultMappings(), new SpecificFuelConsumption(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the SpecificFuelConsumption quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static SpecificFuelConsumptionInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new SpecificFuelConsumptionInfo(nameof(SpecificFuelConsumption), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new SpecificFuelConsumption(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = SpecificFuelConsumptionInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(SpecificFuelConsumption), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new SpecificFuelConsumption(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T][L^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 1, 0, 0, 0, 0); /// /// The default base unit of SpecificFuelConsumption is GramPerKilonewtonSecond. All conversions, as defined in the , go via this value. /// - public static SpecificFuelConsumptionUnit DefaultBaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKilonewtonSecond; + private static SpecificFuelConsumptionUnit DefaultBaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKilonewtonSecond; + + /// + /// The default resource manager for unit abbreviations of the SpecificFuelConsumption quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.SpecificFuelConsumption", typeof(SpecificFuelConsumption).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for SpecificFuelConsumption. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (SpecificFuelConsumptionUnit.GramPerKilonewtonSecond, "GramPerKilonewtonSecond", "GramsPerKilonewtonSecond", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)); yield return new (SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, "KilogramPerKilogramForceHour", "KilogramsPerKilogramForceHour", BaseUnits.Undefined); @@ -128,7 +128,7 @@ public static IEnumerable> GetDefaul static SpecificFuelConsumption() { - Info = SpecificFuelConsumptionInfo.CreateDefault(); + Info = SpecificFuelConsumptionInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 060e7d332b..b79cc8df6e 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class SpecificVolumeInfo: QuantityInfo + private static class SpecificVolumeInfo { - /// - public SpecificVolumeInfo(string name, SpecificVolumeUnit baseUnit, IEnumerable> unitMappings, SpecificVolume zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, SpecificVolume.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public SpecificVolumeInfo(string name, SpecificVolumeUnit baseUnit, IEnumerable> unitMappings, SpecificVolume zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, SpecificVolume.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.SpecificVolume", typeof(SpecificVolume).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the SpecificVolume quantity. - /// - /// A new instance of the class with the default settings. - public static SpecificVolumeInfo CreateDefault() - { - return new SpecificVolumeInfo(nameof(SpecificVolume), DefaultBaseUnit, GetDefaultMappings(), new SpecificVolume(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the SpecificVolume quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static SpecificVolumeInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new SpecificVolumeInfo(nameof(SpecificVolume), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new SpecificVolume(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = SpecificVolumeInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(SpecificVolume), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new SpecificVolume(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^3][M^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, -1, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, -1, 0, 0, 0, 0, 0); /// /// The default base unit of SpecificVolume is CubicMeterPerKilogram. All conversions, as defined in the , go via this value. /// - public static SpecificVolumeUnit DefaultBaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; + private static SpecificVolumeUnit DefaultBaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; + + /// + /// The default resource manager for unit abbreviations of the SpecificVolume quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.SpecificVolume", typeof(SpecificVolume).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for SpecificVolume. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (SpecificVolumeUnit.CubicFootPerPound, "CubicFootPerPound", "CubicFeetPerPound", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); yield return new (SpecificVolumeUnit.CubicMeterPerKilogram, "CubicMeterPerKilogram", "CubicMetersPerKilogram", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefaultMappings static SpecificVolume() { - Info = SpecificVolumeInfo.CreateDefault(); + Info = SpecificVolumeInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 4b409f13cd..afd981750a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -71,59 +71,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class SpecificWeightInfo: QuantityInfo + private static class SpecificWeightInfo { - /// - public SpecificWeightInfo(string name, SpecificWeightUnit baseUnit, IEnumerable> unitMappings, SpecificWeight zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, SpecificWeight.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public SpecificWeightInfo(string name, SpecificWeightUnit baseUnit, IEnumerable> unitMappings, SpecificWeight zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, SpecificWeight.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.SpecificWeight", typeof(SpecificWeight).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the SpecificWeight quantity. - /// - /// A new instance of the class with the default settings. - public static SpecificWeightInfo CreateDefault() - { - return new SpecificWeightInfo(nameof(SpecificWeight), DefaultBaseUnit, GetDefaultMappings(), new SpecificWeight(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the SpecificWeight quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static SpecificWeightInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new SpecificWeightInfo(nameof(SpecificWeight), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new SpecificWeight(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = SpecificWeightInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(SpecificWeight), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new SpecificWeight(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^-2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0); /// /// The default base unit of SpecificWeight is NewtonPerCubicMeter. All conversions, as defined in the , go via this value. /// - public static SpecificWeightUnit DefaultBaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; + private static SpecificWeightUnit DefaultBaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; + + /// + /// The default resource manager for unit abbreviations of the SpecificWeight quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.SpecificWeight", typeof(SpecificWeight).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for SpecificWeight. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (SpecificWeightUnit.KilogramForcePerCubicCentimeter, "KilogramForcePerCubicCentimeter", "KilogramsForcePerCubicCentimeter", BaseUnits.Undefined); yield return new (SpecificWeightUnit.KilogramForcePerCubicMeter, "KilogramForcePerCubicMeter", "KilogramsForcePerCubicMeter", BaseUnits.Undefined); @@ -147,7 +147,7 @@ public static IEnumerable> GetDefaultMappings static SpecificWeight() { - Info = SpecificWeightInfo.CreateDefault(); + Info = SpecificWeightInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 5e2df3f028..a6f9e2c9cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -72,59 +72,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class SpeedInfo: QuantityInfo + private static class SpeedInfo { - /// - public SpeedInfo(string name, SpeedUnit baseUnit, IEnumerable> unitMappings, Speed zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Speed.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public SpeedInfo(string name, SpeedUnit baseUnit, IEnumerable> unitMappings, Speed zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Speed.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Speed", typeof(Speed).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Speed quantity. - /// - /// A new instance of the class with the default settings. - public static SpeedInfo CreateDefault() - { - return new SpeedInfo(nameof(Speed), DefaultBaseUnit, GetDefaultMappings(), new Speed(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Speed quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static SpeedInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new SpeedInfo(nameof(Speed), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Speed(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = SpeedInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Speed), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Speed(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); /// /// The default base unit of Speed is MeterPerSecond. All conversions, as defined in the , go via this value. /// - public static SpeedUnit DefaultBaseUnit { get; } = SpeedUnit.MeterPerSecond; + private static SpeedUnit DefaultBaseUnit { get; } = SpeedUnit.MeterPerSecond; + + /// + /// The default resource manager for unit abbreviations of the Speed quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Speed", typeof(Speed).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Speed. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (SpeedUnit.CentimeterPerHour, "CentimeterPerHour", "CentimetersPerHour", new BaseUnits(length: LengthUnit.Centimeter, time: DurationUnit.Hour)); yield return new (SpeedUnit.CentimeterPerMinute, "CentimeterPerMinute", "CentimetersPerMinute", new BaseUnits(length: LengthUnit.Centimeter, time: DurationUnit.Minute)); @@ -164,7 +164,7 @@ public static IEnumerable> GetDefaultMappings() static Speed() { - Info = SpeedInfo.CreateDefault(); + Info = SpeedInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 65c94b8c28..49d50fc82c 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class StandardVolumeFlowInfo: QuantityInfo + private static class StandardVolumeFlowInfo { - /// - public StandardVolumeFlowInfo(string name, StandardVolumeFlowUnit baseUnit, IEnumerable> unitMappings, StandardVolumeFlow zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, StandardVolumeFlow.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public StandardVolumeFlowInfo(string name, StandardVolumeFlowUnit baseUnit, IEnumerable> unitMappings, StandardVolumeFlow zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, StandardVolumeFlow.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.StandardVolumeFlow", typeof(StandardVolumeFlow).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the StandardVolumeFlow quantity. - /// - /// A new instance of the class with the default settings. - public static StandardVolumeFlowInfo CreateDefault() - { - return new StandardVolumeFlowInfo(nameof(StandardVolumeFlow), DefaultBaseUnit, GetDefaultMappings(), new StandardVolumeFlow(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the StandardVolumeFlow quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static StandardVolumeFlowInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new StandardVolumeFlowInfo(nameof(StandardVolumeFlow), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new StandardVolumeFlow(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = StandardVolumeFlowInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(StandardVolumeFlow), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new StandardVolumeFlow(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); /// /// The default base unit of StandardVolumeFlow is StandardCubicMeterPerSecond. All conversions, as defined in the , go via this value. /// - public static StandardVolumeFlowUnit DefaultBaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; + private static StandardVolumeFlowUnit DefaultBaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; + + /// + /// The default resource manager for unit abbreviations of the StandardVolumeFlow quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.StandardVolumeFlow", typeof(StandardVolumeFlow).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for StandardVolumeFlow. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, "StandardCubicCentimeterPerMinute", "StandardCubicCentimetersPerMinute", new BaseUnits(length: LengthUnit.Centimeter, time: DurationUnit.Minute)); yield return new (StandardVolumeFlowUnit.StandardCubicFootPerHour, "StandardCubicFootPerHour", "StandardCubicFeetPerHour", new BaseUnits(length: LengthUnit.Foot, time: DurationUnit.Hour)); @@ -130,7 +130,7 @@ public static IEnumerable> GetDefaultMapp static StandardVolumeFlow() { - Info = StandardVolumeFlowInfo.CreateDefault(); + Info = StandardVolumeFlowInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index f7172d1193..51b8e2b746 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class TemperatureInfo: QuantityInfo + private static class TemperatureInfo { - /// - public TemperatureInfo(string name, TemperatureUnit baseUnit, IEnumerable> unitMappings, Temperature zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Temperature.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public TemperatureInfo(string name, TemperatureUnit baseUnit, IEnumerable> unitMappings, Temperature zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Temperature.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Temperature", typeof(Temperature).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Temperature quantity. - /// - /// A new instance of the class with the default settings. - public static TemperatureInfo CreateDefault() - { - return new TemperatureInfo(nameof(Temperature), DefaultBaseUnit, GetDefaultMappings(), new Temperature(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Temperature quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static TemperatureInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new TemperatureInfo(nameof(Temperature), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Temperature(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = TemperatureInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Temperature), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Temperature(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [Θ]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); /// /// The default base unit of Temperature is Kelvin. All conversions, as defined in the , go via this value. /// - public static TemperatureUnit DefaultBaseUnit { get; } = TemperatureUnit.Kelvin; + private static TemperatureUnit DefaultBaseUnit { get; } = TemperatureUnit.Kelvin; + + /// + /// The default resource manager for unit abbreviations of the Temperature quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Temperature", typeof(Temperature).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Temperature. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (TemperatureUnit.DegreeCelsius, "DegreeCelsius", "DegreesCelsius", new BaseUnits(temperature: TemperatureUnit.DegreeCelsius)); yield return new (TemperatureUnit.DegreeDelisle, "DegreeDelisle", "DegreesDelisle", new BaseUnits(temperature: TemperatureUnit.DegreeDelisle)); @@ -131,7 +131,7 @@ public static IEnumerable> GetDefaultMappings() static Temperature() { - Info = TemperatureInfo.CreateDefault(); + Info = TemperatureInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index fe135960bc..9c973a3922 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class TemperatureChangeRateInfo: QuantityInfo + private static class TemperatureChangeRateInfo { - /// - public TemperatureChangeRateInfo(string name, TemperatureChangeRateUnit baseUnit, IEnumerable> unitMappings, TemperatureChangeRate zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, TemperatureChangeRate.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public TemperatureChangeRateInfo(string name, TemperatureChangeRateUnit baseUnit, IEnumerable> unitMappings, TemperatureChangeRate zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, TemperatureChangeRate.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.TemperatureChangeRate", typeof(TemperatureChangeRate).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the TemperatureChangeRate quantity. - /// - /// A new instance of the class with the default settings. - public static TemperatureChangeRateInfo CreateDefault() - { - return new TemperatureChangeRateInfo(nameof(TemperatureChangeRate), DefaultBaseUnit, GetDefaultMappings(), new TemperatureChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the TemperatureChangeRate quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static TemperatureChangeRateInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new TemperatureChangeRateInfo(nameof(TemperatureChangeRate), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new TemperatureChangeRate(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = TemperatureChangeRateInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(TemperatureChangeRate), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new TemperatureChangeRate(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][Θ]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, -1, 0, 1, 0, 0); /// /// The default base unit of TemperatureChangeRate is DegreeCelsiusPerSecond. All conversions, as defined in the , go via this value. /// - public static TemperatureChangeRateUnit DefaultBaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; + private static TemperatureChangeRateUnit DefaultBaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; + + /// + /// The default resource manager for unit abbreviations of the TemperatureChangeRate quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.TemperatureChangeRate", typeof(TemperatureChangeRate).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for TemperatureChangeRate. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, "CentidegreeCelsiusPerSecond", "CentidegreesCelsiusPerSecond", BaseUnits.Undefined); yield return new (TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, "DecadegreeCelsiusPerSecond", "DecadegreesCelsiusPerSecond", BaseUnits.Undefined); @@ -141,7 +141,7 @@ public static IEnumerable> GetDefaultM static TemperatureChangeRate() { - Info = TemperatureChangeRateInfo.CreateDefault(); + Info = TemperatureChangeRateInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 280bb277df..977e3efd02 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -71,59 +71,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class TemperatureDeltaInfo: QuantityInfo + private static class TemperatureDeltaInfo { - /// - public TemperatureDeltaInfo(string name, TemperatureDeltaUnit baseUnit, IEnumerable> unitMappings, TemperatureDelta zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, TemperatureDelta.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public TemperatureDeltaInfo(string name, TemperatureDeltaUnit baseUnit, IEnumerable> unitMappings, TemperatureDelta zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, TemperatureDelta.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.TemperatureDelta", typeof(TemperatureDelta).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the TemperatureDelta quantity. - /// - /// A new instance of the class with the default settings. - public static TemperatureDeltaInfo CreateDefault() - { - return new TemperatureDeltaInfo(nameof(TemperatureDelta), DefaultBaseUnit, GetDefaultMappings(), new TemperatureDelta(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the TemperatureDelta quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static TemperatureDeltaInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new TemperatureDeltaInfo(nameof(TemperatureDelta), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new TemperatureDelta(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = TemperatureDeltaInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(TemperatureDelta), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new TemperatureDelta(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [Θ]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); /// /// The default base unit of TemperatureDelta is Kelvin. All conversions, as defined in the , go via this value. /// - public static TemperatureDeltaUnit DefaultBaseUnit { get; } = TemperatureDeltaUnit.Kelvin; + private static TemperatureDeltaUnit DefaultBaseUnit { get; } = TemperatureDeltaUnit.Kelvin; + + /// + /// The default resource manager for unit abbreviations of the TemperatureDelta quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.TemperatureDelta", typeof(TemperatureDelta).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for TemperatureDelta. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (TemperatureDeltaUnit.DegreeCelsius, "DegreeCelsius", "DegreesCelsius", new BaseUnits(temperature: TemperatureUnit.DegreeCelsius)); yield return new (TemperatureDeltaUnit.DegreeDelisle, "DegreeDelisle", "DegreesDelisle", new BaseUnits(temperature: TemperatureUnit.DegreeDelisle)); @@ -139,7 +139,7 @@ public static IEnumerable> GetDefaultMappin static TemperatureDelta() { - Info = TemperatureDeltaInfo.CreateDefault(); + Info = TemperatureDeltaInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 17d57a0d38..405d1b50a0 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class TemperatureGradientInfo: QuantityInfo + private static class TemperatureGradientInfo { - /// - public TemperatureGradientInfo(string name, TemperatureGradientUnit baseUnit, IEnumerable> unitMappings, TemperatureGradient zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, TemperatureGradient.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public TemperatureGradientInfo(string name, TemperatureGradientUnit baseUnit, IEnumerable> unitMappings, TemperatureGradient zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, TemperatureGradient.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.TemperatureGradient", typeof(TemperatureGradient).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the TemperatureGradient quantity. - /// - /// A new instance of the class with the default settings. - public static TemperatureGradientInfo CreateDefault() - { - return new TemperatureGradientInfo(nameof(TemperatureGradient), DefaultBaseUnit, GetDefaultMappings(), new TemperatureGradient(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the TemperatureGradient quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static TemperatureGradientInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new TemperatureGradientInfo(nameof(TemperatureGradient), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new TemperatureGradient(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = TemperatureGradientInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(TemperatureGradient), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new TemperatureGradient(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^-1][Θ]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 0, 0, 1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 0, 0, 0, 1, 0, 0); /// /// The default base unit of TemperatureGradient is KelvinPerMeter. All conversions, as defined in the , go via this value. /// - public static TemperatureGradientUnit DefaultBaseUnit { get; } = TemperatureGradientUnit.KelvinPerMeter; + private static TemperatureGradientUnit DefaultBaseUnit { get; } = TemperatureGradientUnit.KelvinPerMeter; + + /// + /// The default resource manager for unit abbreviations of the TemperatureGradient quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.TemperatureGradient", typeof(TemperatureGradient).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for TemperatureGradient. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (TemperatureGradientUnit.DegreeCelsiusPerKilometer, "DegreeCelsiusPerKilometer", "DegreesCelsiusPerKilometer", new BaseUnits(length: LengthUnit.Kilometer, temperature: TemperatureUnit.DegreeCelsius)); yield return new (TemperatureGradientUnit.DegreeCelsiusPerMeter, "DegreeCelsiusPerMeter", "DegreesCelsiusPerMeter", new BaseUnits(length: LengthUnit.Meter, temperature: TemperatureUnit.DegreeCelsius)); @@ -128,7 +128,7 @@ public static IEnumerable> GetDefaultMap static TemperatureGradient() { - Info = TemperatureGradientInfo.CreateDefault(); + Info = TemperatureGradientInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 3ba31516d3..1b8c5f253d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ThermalConductivityInfo: QuantityInfo + private static class ThermalConductivityInfo { - /// - public ThermalConductivityInfo(string name, ThermalConductivityUnit baseUnit, IEnumerable> unitMappings, ThermalConductivity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ThermalConductivity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ThermalConductivityInfo(string name, ThermalConductivityUnit baseUnit, IEnumerable> unitMappings, ThermalConductivity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ThermalConductivity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ThermalConductivity", typeof(ThermalConductivity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ThermalConductivity quantity. - /// - /// A new instance of the class with the default settings. - public static ThermalConductivityInfo CreateDefault() - { - return new ThermalConductivityInfo(nameof(ThermalConductivity), DefaultBaseUnit, GetDefaultMappings(), new ThermalConductivity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ThermalConductivity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ThermalConductivityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ThermalConductivityInfo(nameof(ThermalConductivity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ThermalConductivity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ThermalConductivityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ThermalConductivity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ThermalConductivity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-3][L][M][Θ^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, 0, -1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 1, -3, 0, -1, 0, 0); /// /// The default base unit of ThermalConductivity is WattPerMeterKelvin. All conversions, as defined in the , go via this value. /// - public static ThermalConductivityUnit DefaultBaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; + private static ThermalConductivityUnit DefaultBaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; + + /// + /// The default resource manager for unit abbreviations of the ThermalConductivity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ThermalConductivity", typeof(ThermalConductivity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ThermalConductivity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ThermalConductivityUnit.BtuPerHourFootFahrenheit, "BtuPerHourFootFahrenheit", "BtusPerHourFootFahrenheit", BaseUnits.Undefined); yield return new (ThermalConductivityUnit.WattPerMeterKelvin, "WattPerMeterKelvin", "WattsPerMeterKelvin", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, temperature: TemperatureUnit.Kelvin)); @@ -126,7 +126,7 @@ public static IEnumerable> GetDefaultMap static ThermalConductivity() { - Info = ThermalConductivityInfo.CreateDefault(); + Info = ThermalConductivityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs index b89a424425..16b66d0270 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class ThermalInsulanceInfo: QuantityInfo + private static class ThermalInsulanceInfo { - /// - public ThermalInsulanceInfo(string name, ThermalInsulanceUnit baseUnit, IEnumerable> unitMappings, ThermalInsulance zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, ThermalInsulance.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public ThermalInsulanceInfo(string name, ThermalInsulanceUnit baseUnit, IEnumerable> unitMappings, ThermalInsulance zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, ThermalInsulance.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.ThermalInsulance", typeof(ThermalInsulance).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the ThermalInsulance quantity. - /// - /// A new instance of the class with the default settings. - public static ThermalInsulanceInfo CreateDefault() - { - return new ThermalInsulanceInfo(nameof(ThermalInsulance), DefaultBaseUnit, GetDefaultMappings(), new ThermalInsulance(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the ThermalInsulance quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static ThermalInsulanceInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new ThermalInsulanceInfo(nameof(ThermalInsulance), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new ThermalInsulance(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = ThermalInsulanceInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(ThermalInsulance), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new ThermalInsulance(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^3][M^-1][Θ]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, -1, 3, 0, 1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(0, -1, 3, 0, 1, 0, 0); /// /// The default base unit of ThermalInsulance is SquareMeterKelvinPerKilowatt. All conversions, as defined in the , go via this value. /// - public static ThermalInsulanceUnit DefaultBaseUnit { get; } = ThermalInsulanceUnit.SquareMeterKelvinPerKilowatt; + private static ThermalInsulanceUnit DefaultBaseUnit { get; } = ThermalInsulanceUnit.SquareMeterKelvinPerKilowatt; + + /// + /// The default resource manager for unit abbreviations of the ThermalInsulance quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.ThermalInsulance", typeof(ThermalInsulance).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for ThermalInsulance. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (ThermalInsulanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, "HourSquareFeetDegreeFahrenheitPerBtu", "HourSquareFeetDegreesFahrenheitPerBtu", BaseUnits.Undefined); yield return new (ThermalInsulanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, "SquareCentimeterHourDegreeCelsiusPerKilocalorie", "SquareCentimeterHourDegreesCelsiusPerKilocalorie", BaseUnits.Undefined); @@ -128,7 +128,7 @@ public static IEnumerable> GetDefaultMappin static ThermalInsulance() { - Info = ThermalInsulanceInfo.CreateDefault(); + Info = ThermalInsulanceInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 76f51c5df6..2324c955bc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -71,59 +71,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class TorqueInfo: QuantityInfo + private static class TorqueInfo { - /// - public TorqueInfo(string name, TorqueUnit baseUnit, IEnumerable> unitMappings, Torque zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Torque.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public TorqueInfo(string name, TorqueUnit baseUnit, IEnumerable> unitMappings, Torque zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Torque.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Torque", typeof(Torque).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Torque quantity. - /// - /// A new instance of the class with the default settings. - public static TorqueInfo CreateDefault() - { - return new TorqueInfo(nameof(Torque), DefaultBaseUnit, GetDefaultMappings(), new Torque(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Torque quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static TorqueInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new TorqueInfo(nameof(Torque), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Torque(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = TorqueInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Torque), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Torque(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^2][M]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); /// /// The default base unit of Torque is NewtonMeter. All conversions, as defined in the , go via this value. /// - public static TorqueUnit DefaultBaseUnit { get; } = TorqueUnit.NewtonMeter; + private static TorqueUnit DefaultBaseUnit { get; } = TorqueUnit.NewtonMeter; + + /// + /// The default resource manager for unit abbreviations of the Torque quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Torque", typeof(Torque).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Torque. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (TorqueUnit.GramForceCentimeter, "GramForceCentimeter", "GramForceCentimeters", BaseUnits.Undefined); yield return new (TorqueUnit.GramForceMeter, "GramForceMeter", "GramForceMeters", BaseUnits.Undefined); @@ -155,7 +155,7 @@ public static IEnumerable> GetDefaultMappings() static Torque() { - Info = TorqueInfo.CreateDefault(); + Info = TorqueInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 16c9f1f366..dccfffd7d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class TurbidityInfo: QuantityInfo + private static class TurbidityInfo { - /// - public TurbidityInfo(string name, TurbidityUnit baseUnit, IEnumerable> unitMappings, Turbidity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Turbidity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public TurbidityInfo(string name, TurbidityUnit baseUnit, IEnumerable> unitMappings, Turbidity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Turbidity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Turbidity", typeof(Turbidity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Turbidity quantity. - /// - /// A new instance of the class with the default settings. - public static TurbidityInfo CreateDefault() - { - return new TurbidityInfo(nameof(Turbidity), DefaultBaseUnit, GetDefaultMappings(), new Turbidity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Turbidity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static TurbidityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new TurbidityInfo(nameof(Turbidity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Turbidity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = TurbidityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Turbidity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Turbidity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of Turbidity is NTU. All conversions, as defined in the , go via this value. /// - public static TurbidityUnit DefaultBaseUnit { get; } = TurbidityUnit.NTU; + private static TurbidityUnit DefaultBaseUnit { get; } = TurbidityUnit.NTU; + + /// + /// The default resource manager for unit abbreviations of the Turbidity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Turbidity", typeof(Turbidity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Turbidity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (TurbidityUnit.NTU, "NTU", "NTU", BaseUnits.Undefined); } @@ -125,7 +125,7 @@ public static IEnumerable> GetDefaultMappings() static Turbidity() { - Info = TurbidityInfo.CreateDefault(); + Info = TurbidityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index e5a8a896f9..fa753bc696 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class VitaminAInfo: QuantityInfo + private static class VitaminAInfo { - /// - public VitaminAInfo(string name, VitaminAUnit baseUnit, IEnumerable> unitMappings, VitaminA zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, VitaminA.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public VitaminAInfo(string name, VitaminAUnit baseUnit, IEnumerable> unitMappings, VitaminA zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, VitaminA.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.VitaminA", typeof(VitaminA).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the VitaminA quantity. - /// - /// A new instance of the class with the default settings. - public static VitaminAInfo CreateDefault() - { - return new VitaminAInfo(nameof(VitaminA), DefaultBaseUnit, GetDefaultMappings(), new VitaminA(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the VitaminA quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static VitaminAInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new VitaminAInfo(nameof(VitaminA), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new VitaminA(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = VitaminAInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(VitaminA), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new VitaminA(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of VitaminA is InternationalUnit. All conversions, as defined in the , go via this value. /// - public static VitaminAUnit DefaultBaseUnit { get; } = VitaminAUnit.InternationalUnit; + private static VitaminAUnit DefaultBaseUnit { get; } = VitaminAUnit.InternationalUnit; + + /// + /// The default resource manager for unit abbreviations of the VitaminA quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.VitaminA", typeof(VitaminA).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for VitaminA. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (VitaminAUnit.InternationalUnit, "InternationalUnit", "InternationalUnits", BaseUnits.Undefined); } @@ -122,7 +122,7 @@ public static IEnumerable> GetDefaultMappings() static VitaminA() { - Info = VitaminAInfo.CreateDefault(); + Info = VitaminAInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 6b4e5d3445..3554b66532 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -77,59 +77,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class VolumeInfo: QuantityInfo + private static class VolumeInfo { - /// - public VolumeInfo(string name, VolumeUnit baseUnit, IEnumerable> unitMappings, Volume zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, Volume.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public VolumeInfo(string name, VolumeUnit baseUnit, IEnumerable> unitMappings, Volume zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, Volume.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.Volume", typeof(Volume).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the Volume quantity. - /// - /// A new instance of the class with the default settings. - public static VolumeInfo CreateDefault() - { - return new VolumeInfo(nameof(Volume), DefaultBaseUnit, GetDefaultMappings(), new Volume(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the Volume quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static VolumeInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new VolumeInfo(nameof(Volume), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new Volume(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = VolumeInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(Volume), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new Volume(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^3]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, 0, 0, 0, 0, 0, 0); /// /// The default base unit of Volume is CubicMeter. All conversions, as defined in the , go via this value. /// - public static VolumeUnit DefaultBaseUnit { get; } = VolumeUnit.CubicMeter; + private static VolumeUnit DefaultBaseUnit { get; } = VolumeUnit.CubicMeter; + + /// + /// The default resource manager for unit abbreviations of the Volume quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.Volume", typeof(Volume).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for Volume. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (VolumeUnit.AcreFoot, "AcreFoot", "AcreFeet", BaseUnits.Undefined); yield return new (VolumeUnit.AuTablespoon, "AuTablespoon", "AuTablespoons", BaseUnits.Undefined); @@ -190,7 +190,7 @@ public static IEnumerable> GetDefaultMappings() static Volume() { - Info = VolumeInfo.CreateDefault(); + Info = VolumeInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 5b7fd3a33e..e2b7e3fb89 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -69,59 +69,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class VolumeConcentrationInfo: QuantityInfo + private static class VolumeConcentrationInfo { - /// - public VolumeConcentrationInfo(string name, VolumeConcentrationUnit baseUnit, IEnumerable> unitMappings, VolumeConcentration zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, VolumeConcentration.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public VolumeConcentrationInfo(string name, VolumeConcentrationUnit baseUnit, IEnumerable> unitMappings, VolumeConcentration zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, VolumeConcentration.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.VolumeConcentration", typeof(VolumeConcentration).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the VolumeConcentration quantity. - /// - /// A new instance of the class with the default settings. - public static VolumeConcentrationInfo CreateDefault() - { - return new VolumeConcentrationInfo(nameof(VolumeConcentration), DefaultBaseUnit, GetDefaultMappings(), new VolumeConcentration(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the VolumeConcentration quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static VolumeConcentrationInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new VolumeConcentrationInfo(nameof(VolumeConcentration), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new VolumeConcentration(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = VolumeConcentrationInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(VolumeConcentration), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new VolumeConcentration(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is . /// - public static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; + private static BaseDimensions DefaultBaseDimensions { get; } = BaseDimensions.Dimensionless; /// /// The default base unit of VolumeConcentration is DecimalFraction. All conversions, as defined in the , go via this value. /// - public static VolumeConcentrationUnit DefaultBaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; + private static VolumeConcentrationUnit DefaultBaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; + + /// + /// The default resource manager for unit abbreviations of the VolumeConcentration quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.VolumeConcentration", typeof(VolumeConcentration).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for VolumeConcentration. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (VolumeConcentrationUnit.CentiliterPerLiter, "CentiliterPerLiter", "CentilitersPerLiter", BaseUnits.Undefined); yield return new (VolumeConcentrationUnit.CentiliterPerMilliliter, "CentiliterPerMilliliter", "CentilitersPerMilliliter", BaseUnits.Undefined); @@ -148,7 +148,7 @@ public static IEnumerable> GetDefaultMap static VolumeConcentration() { - Info = VolumeConcentrationInfo.CreateDefault(); + Info = VolumeConcentrationInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 6172f3fe20..23fd94a055 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -69,59 +69,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class VolumeFlowInfo: QuantityInfo + private static class VolumeFlowInfo { - /// - public VolumeFlowInfo(string name, VolumeFlowUnit baseUnit, IEnumerable> unitMappings, VolumeFlow zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, VolumeFlow.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public VolumeFlowInfo(string name, VolumeFlowUnit baseUnit, IEnumerable> unitMappings, VolumeFlow zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, VolumeFlow.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.VolumeFlow", typeof(VolumeFlow).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the VolumeFlow quantity. - /// - /// A new instance of the class with the default settings. - public static VolumeFlowInfo CreateDefault() - { - return new VolumeFlowInfo(nameof(VolumeFlow), DefaultBaseUnit, GetDefaultMappings(), new VolumeFlow(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the VolumeFlow quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static VolumeFlowInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new VolumeFlowInfo(nameof(VolumeFlow), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new VolumeFlow(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = VolumeFlowInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(VolumeFlow), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new VolumeFlow(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L^3]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(3, 0, -1, 0, 0, 0, 0); /// /// The default base unit of VolumeFlow is CubicMeterPerSecond. All conversions, as defined in the , go via this value. /// - public static VolumeFlowUnit DefaultBaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; + private static VolumeFlowUnit DefaultBaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; + + /// + /// The default resource manager for unit abbreviations of the VolumeFlow quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.VolumeFlow", typeof(VolumeFlow).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for VolumeFlow. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (VolumeFlowUnit.AcreFootPerDay, "AcreFootPerDay", "AcreFeetPerDay", BaseUnits.Undefined); yield return new (VolumeFlowUnit.AcreFootPerHour, "AcreFootPerHour", "AcreFeetPerHour", BaseUnits.Undefined); @@ -203,7 +203,7 @@ public static IEnumerable> GetDefaultMappings() static VolumeFlow() { - Info = VolumeFlowInfo.CreateDefault(); + Info = VolumeFlowInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index c824b09152..5bf65a1af2 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class VolumeFlowPerAreaInfo: QuantityInfo + private static class VolumeFlowPerAreaInfo { - /// - public VolumeFlowPerAreaInfo(string name, VolumeFlowPerAreaUnit baseUnit, IEnumerable> unitMappings, VolumeFlowPerArea zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, VolumeFlowPerArea.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public VolumeFlowPerAreaInfo(string name, VolumeFlowPerAreaUnit baseUnit, IEnumerable> unitMappings, VolumeFlowPerArea zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, VolumeFlowPerArea.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.VolumeFlowPerArea", typeof(VolumeFlowPerArea).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the VolumeFlowPerArea quantity. - /// - /// A new instance of the class with the default settings. - public static VolumeFlowPerAreaInfo CreateDefault() - { - return new VolumeFlowPerAreaInfo(nameof(VolumeFlowPerArea), DefaultBaseUnit, GetDefaultMappings(), new VolumeFlowPerArea(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the VolumeFlowPerArea quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static VolumeFlowPerAreaInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new VolumeFlowPerAreaInfo(nameof(VolumeFlowPerArea), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new VolumeFlowPerArea(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = VolumeFlowPerAreaInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(VolumeFlowPerArea), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new VolumeFlowPerArea(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-1][L]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); /// /// The default base unit of VolumeFlowPerArea is CubicMeterPerSecondPerSquareMeter. All conversions, as defined in the , go via this value. /// - public static VolumeFlowPerAreaUnit DefaultBaseUnit { get; } = VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter; + private static VolumeFlowPerAreaUnit DefaultBaseUnit { get; } = VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter; + + /// + /// The default resource manager for unit abbreviations of the VolumeFlowPerArea quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.VolumeFlowPerArea", typeof(VolumeFlowPerArea).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for VolumeFlowPerArea. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, "CubicFootPerMinutePerSquareFoot", "CubicFeetPerMinutePerSquareFoot", new BaseUnits(length: LengthUnit.Foot, time: DurationUnit.Minute)); yield return new (VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, "CubicMeterPerSecondPerSquareMeter", "CubicMetersPerSecondPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)); @@ -123,7 +123,7 @@ public static IEnumerable> GetDefaultMappi static VolumeFlowPerArea() { - Info = VolumeFlowPerAreaInfo.CreateDefault(); + Info = VolumeFlowPerAreaInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 6fb629c874..62ad50ae9c 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class VolumePerLengthInfo: QuantityInfo + private static class VolumePerLengthInfo { - /// - public VolumePerLengthInfo(string name, VolumePerLengthUnit baseUnit, IEnumerable> unitMappings, VolumePerLength zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, VolumePerLength.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public VolumePerLengthInfo(string name, VolumePerLengthUnit baseUnit, IEnumerable> unitMappings, VolumePerLength zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, VolumePerLength.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.VolumePerLength", typeof(VolumePerLength).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the VolumePerLength quantity. - /// - /// A new instance of the class with the default settings. - public static VolumePerLengthInfo CreateDefault() - { - return new VolumePerLengthInfo(nameof(VolumePerLength), DefaultBaseUnit, GetDefaultMappings(), new VolumePerLength(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the VolumePerLength quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static VolumePerLengthInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new VolumePerLengthInfo(nameof(VolumePerLength), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new VolumePerLength(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = VolumePerLengthInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(VolumePerLength), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new VolumePerLength(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^2]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); /// /// The default base unit of VolumePerLength is CubicMeterPerMeter. All conversions, as defined in the , go via this value. /// - public static VolumePerLengthUnit DefaultBaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; + private static VolumePerLengthUnit DefaultBaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; + + /// + /// The default resource manager for unit abbreviations of the VolumePerLength quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.VolumePerLength", typeof(VolumePerLength).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for VolumePerLength. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (VolumePerLengthUnit.CubicMeterPerMeter, "CubicMeterPerMeter", "CubicMetersPerMeter", new BaseUnits(length: LengthUnit.Meter)); yield return new (VolumePerLengthUnit.CubicYardPerFoot, "CubicYardPerFoot", "CubicYardsPerFoot", BaseUnits.Undefined); @@ -130,7 +130,7 @@ public static IEnumerable> GetDefaultMapping static VolumePerLength() { - Info = VolumePerLengthInfo.CreateDefault(); + Info = VolumePerLengthInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 0efd21e0e1..700492be85 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -65,59 +65,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class VolumetricHeatCapacityInfo: QuantityInfo + private static class VolumetricHeatCapacityInfo { - /// - public VolumetricHeatCapacityInfo(string name, VolumetricHeatCapacityUnit baseUnit, IEnumerable> unitMappings, VolumetricHeatCapacity zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, VolumetricHeatCapacity.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public VolumetricHeatCapacityInfo(string name, VolumetricHeatCapacityUnit baseUnit, IEnumerable> unitMappings, VolumetricHeatCapacity zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, VolumetricHeatCapacity.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.VolumetricHeatCapacity", typeof(VolumetricHeatCapacity).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the VolumetricHeatCapacity quantity. - /// - /// A new instance of the class with the default settings. - public static VolumetricHeatCapacityInfo CreateDefault() - { - return new VolumetricHeatCapacityInfo(nameof(VolumetricHeatCapacity), DefaultBaseUnit, GetDefaultMappings(), new VolumetricHeatCapacity(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the VolumetricHeatCapacity quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static VolumetricHeatCapacityInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new VolumetricHeatCapacityInfo(nameof(VolumetricHeatCapacity), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new VolumetricHeatCapacity(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = VolumetricHeatCapacityInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(VolumetricHeatCapacity), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new VolumetricHeatCapacity(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [T^-2][L^-1][M][Θ^-1]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -2, 0, -1, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(-1, 1, -2, 0, -1, 0, 0); /// /// The default base unit of VolumetricHeatCapacity is JoulePerCubicMeterKelvin. All conversions, as defined in the , go via this value. /// - public static VolumetricHeatCapacityUnit DefaultBaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; + private static VolumetricHeatCapacityUnit DefaultBaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; + + /// + /// The default resource manager for unit abbreviations of the VolumetricHeatCapacity quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.VolumetricHeatCapacity", typeof(VolumetricHeatCapacity).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for VolumetricHeatCapacity. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, "BtuPerCubicFootDegreeFahrenheit", "BtusPerCubicFootDegreeFahrenheit", BaseUnits.Undefined); yield return new (VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, "CaloriePerCubicCentimeterDegreeCelsius", "CaloriesPerCubicCentimeterDegreeCelsius", BaseUnits.Undefined); @@ -133,7 +133,7 @@ public static IEnumerable> GetDefault static VolumetricHeatCapacity() { - Info = VolumetricHeatCapacityInfo.CreateDefault(); + Info = VolumetricHeatCapacityInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); } diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 4e61b90bf2..77eec49cd5 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -62,59 +62,59 @@ namespace UnitsNet /// /// Provides detailed information about the quantity, including its name, base unit, unit mappings, base dimensions, and conversion functions. /// - public sealed class WarpingMomentOfInertiaInfo: QuantityInfo + private static class WarpingMomentOfInertiaInfo { - /// - public WarpingMomentOfInertiaInfo(string name, WarpingMomentOfInertiaUnit baseUnit, IEnumerable> unitMappings, WarpingMomentOfInertia zero, BaseDimensions baseDimensions, - QuantityFromDelegate fromDelegate, ResourceManager? unitAbbreviations) - : base(name, baseUnit, unitMappings, zero, baseDimensions, fromDelegate, WarpingMomentOfInertia.RegisterDefaultConversions, unitAbbreviations) - { - } - - /// - public WarpingMomentOfInertiaInfo(string name, WarpingMomentOfInertiaUnit baseUnit, IEnumerable> unitMappings, WarpingMomentOfInertia zero, BaseDimensions baseDimensions) - : this(name, baseUnit, unitMappings, zero, baseDimensions, WarpingMomentOfInertia.From, new ResourceManager("UnitsNet.GeneratedCode.Resources.WarpingMomentOfInertia", typeof(WarpingMomentOfInertia).Assembly)) - { - } - - /// - /// Creates a new instance of the class with the default settings for the WarpingMomentOfInertia quantity. - /// - /// A new instance of the class with the default settings. - public static WarpingMomentOfInertiaInfo CreateDefault() - { - return new WarpingMomentOfInertiaInfo(nameof(WarpingMomentOfInertia), DefaultBaseUnit, GetDefaultMappings(), new WarpingMomentOfInertia(0, DefaultBaseUnit), DefaultBaseDimensions); - } - /// /// Creates a new instance of the class with the default settings for the WarpingMomentOfInertia quantity and a callback for customizing the default unit mappings. /// + /// + /// When provided, the resource manager used for localizing the quantity's unit abbreviations. Defaults to the built-in abbreviations. + /// /// - /// A callback function for customizing the default unit mappings. + /// Optionally add, replace or remove unit definitions from the default set of units. /// /// /// A new instance of the class with the default settings. /// - public static WarpingMomentOfInertiaInfo CreateDefault(Func>, IEnumerable>> customizeUnits) + private static QuantityInfo Create( + ResourceManager? unitAbbreviations = null, + Func>, IEnumerable>>? customizeUnits = null) { - return new WarpingMomentOfInertiaInfo(nameof(WarpingMomentOfInertia), DefaultBaseUnit, customizeUnits(GetDefaultMappings()), new WarpingMomentOfInertia(0, DefaultBaseUnit), DefaultBaseDimensions); + IEnumerable> unitMappings = WarpingMomentOfInertiaInfo.GetDefaultMappings(); + if (customizeUnits != null) + unitMappings = customizeUnits(unitMappings); + + return new QuantityInfo( + name: nameof(WarpingMomentOfInertia), + baseUnit: DefaultBaseUnit, + unitMappings: unitMappings, + zero: new WarpingMomentOfInertia(0, DefaultBaseUnit), + baseDimensions: DefaultBaseDimensions, + fromDelegate: From, + registerUnitConversions: RegisterDefaultConversions, + unitAbbreviations ?? DefaultUnitAbbreviations); } /// /// The for is [L^6]. /// - public static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(6, 0, 0, 0, 0, 0, 0); + private static BaseDimensions DefaultBaseDimensions { get; } = new BaseDimensions(6, 0, 0, 0, 0, 0, 0); /// /// The default base unit of WarpingMomentOfInertia is MeterToTheSixth. All conversions, as defined in the , go via this value. /// - public static WarpingMomentOfInertiaUnit DefaultBaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; + private static WarpingMomentOfInertiaUnit DefaultBaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; + + /// + /// The default resource manager for unit abbreviations of the WarpingMomentOfInertia quantity. + /// + private static ResourceManager DefaultUnitAbbreviations { get; } = new("UnitsNet.GeneratedCode.Resources.WarpingMomentOfInertia", typeof(WarpingMomentOfInertia).Assembly); /// /// Retrieves the default mappings for . /// /// An of representing the default unit mappings for WarpingMomentOfInertia. - public static IEnumerable> GetDefaultMappings() + private static IEnumerable> GetDefaultMappings() { yield return new (WarpingMomentOfInertiaUnit.CentimeterToTheSixth, "CentimeterToTheSixth", "CentimetersToTheSixth", new BaseUnits(length: LengthUnit.Centimeter)); yield return new (WarpingMomentOfInertiaUnit.DecimeterToTheSixth, "DecimeterToTheSixth", "DecimetersToTheSixth", new BaseUnits(length: LengthUnit.Decimeter)); @@ -127,7 +127,7 @@ public static IEnumerable> GetDefault static WarpingMomentOfInertia() { - Info = WarpingMomentOfInertiaInfo.CreateDefault(); + Info = WarpingMomentOfInertiaInfo.Create(); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); }