diff --git a/README.md b/README.md index 7e0d49eaad..3f606ccbf2 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ See [Upgrading from 3.x to 4.x](https://github.com/angularsen/UnitsNet/wiki/Upgr * [Statically typed quantities and units](#static-typing) to avoid mistakes and communicate intent * [Operator overloads](#operator-overloads) for arithmetic on quantities * [Parse and ToString()](#culture) supports cultures and localization -* [Dynamically parsing and converting](#dynamic-parsing) quantities and units +* [Dynamically parse and convert](#dynamic-parsing) quantities and units * [Example: Creating a unit converter app](#example-app) * [Example: WPF app using IValueConverter to parse quantities from input](#example-wpf-app-using-ivalueconverter-to-parse-quantities-from-input) * [Precision and accuracy](#precision) @@ -125,29 +125,105 @@ Unfortunately there is no built-in way to avoid this, either you need to ensure Example: `Length.Parse("1 pt")` throws `AmbiguousUnitParseException` with message `Cannot parse "pt" since it could be either of these: DtpPoint, PrinterPoint`. -### Dynamically Parsing and Converting Quantities +### Dynamically Parse Quantities and Convert to Units Sometimes you need to work with quantities and units at runtime, such as parsing user input. -There are three classes to help with this: -- [UnitParser](UnitsNet/CustomCode/UnitParser.cs) for parsing unit abbreviation strings like `cm` to `LengthUnit.Centimeter` -- [UnitAbbreviationsCache](UnitsNet/CustomCode/UnitAbbreviationsCache.cs) for looking up unit abbreviations like `cm` given type `LengthUnit` and value `1` (`Centimeter`) -- [UnitConverter](UnitsNet/UnitConverter.cs) for converting values given a quantity name `Length`, a value `1` and from/to unit names `Centimeter` and `Meter` + +There are a handful of classes to help with this: + +- [Quantity](UnitsNet/CustomCode/Quantity.cs) for parsing and constructing quantities as well as looking up units, names and quantity information dynamically +- [UnitConverter](UnitsNet/UnitConverter.cs) for converting values to a different unit, with only strings or enum values +- [UnitParser](UnitsNet/CustomCode/UnitParser.cs) for parsing unit abbreviation strings, such as `"cm"` to `LengthUnit.Centimeter` + +#### Enumerate quantities and units +`Quantity` is the go-to class for looking up information about quantities at runtime. +```c# +string[] Quantity.Names; // ["Length", "Mass", ...] +QuantityType[] Quantity.Types; // [QuantityType.Length, QuantityType.Mass, ...] +QuantityInfo[] Quantity.Infos; // Information about all quantities and their units, types, values etc., see more below + +QuantityInfo Quantity.GetInfo(QuantityType.Length); // Get information about Length +``` + +#### Information about quantity type +`QuantityInfo` makes it easy to enumerate names, units, types and values for the quantity type. +This is useful for populating lists of quantities and units for the user to choose. + +```c# +QuantityInfo lengthInfo = Quantity.GetInfo(QuantityType.Length); // You can get it statically here +lengthInfo = Length.Info; // or statically per quantity +lengthInfo = Length.Zero.QuantityInfo; // or dynamically from quantity instances + +lengthInfo.Name; // "Length" +lengthInfo.QuantityType; // QuantityType.Length +lengthInfo.UnitNames; // ["Centimeter", "Meter", ...] +lengthInfo.Units; // [LengthUnit.Centimeter, LengthUnit.Meter, ...] +lengthInfo.UnitType; // typeof(LengthUnit) +lengthInfo.ValueType; // typeof(Length) +lengthInfo.Zero; // Length.Zero +``` + +#### Construct quantity +All you need is the value and the unit enum value. + +```c# +IQuantity quantity = Quantity.From(3, LengthUnit.Centimeter); // Length + +if (Quantity.TryFrom(3, LengthUnit.Centimeter, out IQuantity quantity2)) +{ +} +``` +#### Parse quantity +Parse any string to a quantity instance of the given the quantity type. + +```c# +IQuantity quantity = Quantity.Parse(typeof(Length), "3 cm"); // Length + +if (Quantity.TryParse(typeof(Length), "3cm", out IQuantity quantity2) +{ +} +``` + +#### Parse unit +[UnitParser](UnitsNet/CustomCode/UnitParser.cs) parses unit abbreviation strings to unit enum values. ```c# -// This type was perhaps selected by the user in GUI from a list of units -Type lengthUnitType = typeof(LengthUnit); // Selected by user in GUI from a list of units +Enum unit = UnitParser.Default.Parse("cm", typeof(LengthUnit)); // LengthUnit.Centimeter -// Parse units dynamically -UnitParser parser = UnitParser.Default; -int fromUnitValue = (int)parser.Parse("cm", lengthUnitType); // LengthUnit.Centimeter == 1 +if (UnitParser.Default.TryParse("cm", typeof(LengthUnit), out Enum unit2)) +{ + // Use unit2 as LengthUnit.Centimeter +} +``` -// Get unit abbreviations dynamically -var cache = UnitAbbreviationsCache.Default; -string fromUnitAbbreviation = cache.GetDefaultAbbreviation(lengthUnitType, 1); // "cm" +#### Convert quantity to unit - IQuantity and Enum +Convert any `IQuantity` instance to a different unit by providing a target unit enum value. +```c# +// Assume these are passed in at runtime, we don't know their values or type +Enum userSelectedUnit = LengthUnit.Millimeter; +IQuantity quantity = Length.FromCentimeters(3); + +// Later we convert to a unit +quantity.ToUnit(userSelectedUnit).Value; // 30 +quantity.ToUnit(userSelectedUnit).Unit; // LengthUnit.Millimeter +quantity.ToUnit(userSelectedUnit).ToString(); // "30 mm" +quantity.ToUnit(PressureUnit.Pascal); // Throws exception, not compatible +quantity.As(userSelectedUnit); // 30 +``` -double centimeters = UnitConverter.ConvertByName(1, "Length", "Meter", "Centimeter"); // 100 +#### Convert quantity to unit - From/To Enums +Useful when populating lists with unit enum values for the user to choose. + +```c# +UnitConverter.Convert(1, LengthUnit.Centimeter, LengthUnit.Millimeter); // 10 mm ``` -For more examples on dynamic parsing and conversion, see the unit conversion applications below. +#### Convert quantity to unit - Names or abbreviation strings +Sometimes you only have strings to work with, that works too! + +```c# +UnitConverter.ConvertByName(1, "Length", "Centimeter", "Millimeter"); // 10 mm +UnitConverter.ConvertByAbbreviation(1, "Length", "cm", "mm"); // 10 mm +``` ### Example: Creating a dynamic unit converter app [Source code](https://github.com/angularsen/UnitsNet/tree/master/Samples/UnitConverter.Wpf) for `Samples/UnitConverter.Wpf`
@@ -156,25 +232,37 @@ For more examples on dynamic parsing and conversion, see the unit conversion app ![image](https://user-images.githubusercontent.com/787816/34920961-9b697004-f97b-11e7-9e9a-51ff7142969b.png) -This example shows how you can create a dynamic unit converter, where the user selects the quantity to convert, such as `Length` or `Mass`, then selects to convert from `Meter` to `Centimeter` and types in a value for how many meters. +This example shows how you can create a dynamic unit converter, where the user selects the quantity to convert, such as `Temperature`, then selects to convert from `DegreeCelsius` to `DegreeFahrenheit` and types in a numeric value for how many degrees Celsius to convert. +The quantity list box contains `QuantityType` values such as `QuantityType.Length` and the two unit list boxes contain `Enum` values, such as `LengthUnit.Meter`. -NOTE: There are still some limitations in the library that requires reflection to enumerate units for quantity and getting the abbreviation for a unit, when we want to dynamically enumerate and convert between units. +#### Populate quantity selector +Use `Quantity` to enumerate all quantity type enum values, such as `QuantityType.Length` and `QuantityType.Mass`. -### Example: Creating a unit converter app with hard coded quantities +```c# +this.Quantities = Quantity.Types; // QuantityType[] +``` -If you can live with hard coding what quantities to convert between, then the following code snippet shows you one way to go about it: +#### Update unit lists when selecting new quantity +So user can only choose from/to units compatible with the quantity type. -```C# -// Get quantities for populating quantity UI selector -QuantityType[] quantityTypes = Enum.GetValues(typeof(QuantityType)).Cast().ToArray(); +```c# +QuantityInfo quantityInfo = Quantity.GetInfo(quantityType); -// If Length is selected, get length units for populating from/to UI selectors -LengthUnit[] lengthUnits = Length.Units; +_units.Clear(); +foreach (Enum unitValue in quantityInfo.Units) +{ + _units.Add(unitValue); +} +``` + +#### Update calculation on unit selection changed +Using `UnitConverter` to convert by unit enum values as given by the list selection `"Length"` and unit names like `"Centimeter"` and `"Meter"`. -// Perform conversion using input value and selected from/to units -double inputValue; // Obtain from textbox -LengthUnit fromUnit, toUnit; // Obtain from ListBox selections -double resultValue = Length.From(inputValue, fromUnit).As(toUnit); +```c# +double convertedValue = UnitConverter.Convert( + FromValue, // numeric value + SelectedFromUnit.UnitEnumValue, // Enum, such as LengthUnit.Meter + SelectedToUnit.UnitEnumValue); // Enum, such as LengthUnit.Centimeter ``` ### Example: WPF app using IValueConverter to parse quantities from input @@ -183,11 +271,8 @@ Src: [Samples/WpfMVVMSample](https://github.com/angularsen/UnitsNet/tree/master/ ![wpfmvvmsample_219w](https://user-images.githubusercontent.com/787816/34913417-094332e2-f8fd-11e7-9d8a-92db105fbbc9.png) - The purpose of this app is to show how to create an `IValueConverter` in order to bind XAML to quantities. -NOTE: A lot of reflection and complexity were introduced due to not having a base type. See #371 for discussion on adding base types. - ### Precision and Accuracy A base unit is chosen for each unit class, represented by a double value (64-bit), and all conversions go via this unit. This means that there will always be a small error in both representing other units than the base unit as well as converting between units. diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/DelegateCommand.cs b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/DelegateCommand.cs index b45ce23107..7a771fc722 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/DelegateCommand.cs +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/DelegateCommand.cs @@ -26,6 +26,9 @@ public void Execute(object parameter) _commandDelegate.Invoke(); } + // Is never used +#pragma warning disable CS0067 public event EventHandler CanExecuteChanged; +#pragma warning restore CS0067 } -} \ No newline at end of file +} diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs index c062f6d460..dcf70b3d4d 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs @@ -27,4 +27,4 @@ public interface IMainWindowVm : INotifyPropertyChanged decimal ToValue { get; } ICommand SwapCommand { get; } } -} \ No newline at end of file +} diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowDesignVM.cs b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowDesignVM.cs index b97fe92bcb..379acaa380 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowDesignVM.cs +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowDesignVM.cs @@ -1,8 +1,8 @@ -using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; +using System.Runtime.CompilerServices; using System.Windows.Input; namespace UnitsNet.Samples.UnitConverter.Wpf @@ -15,13 +15,14 @@ public sealed class MainWindowDesignVm : IMainWindowVm { public MainWindowDesignVm() { - Quantities = ToReadOnly(Enum.GetValues(typeof(QuantityType)).Cast().Skip(1)); + Quantities = ToReadOnly(Quantity.Types); Units = ToReadOnly(Length.Units.Select(u => new UnitListItem(u))); SelectedQuantity = QuantityType.Length; SelectedFromUnit = Units[1]; SelectedToUnit = Units[2]; } + public ReadOnlyObservableCollection Quantities { get; } public ReadOnlyObservableCollection Units { get; } public QuantityType SelectedQuantity { get; set; } @@ -35,11 +36,14 @@ public MainWindowDesignVm() public ICommand SwapCommand { get; } = new RoutedCommand(); + // Is never used +#pragma warning disable CS0067 public event PropertyChangedEventHandler PropertyChanged; +#pragma warning restore CS0067 private static ReadOnlyObservableCollection ToReadOnly(IEnumerable items) { return new ReadOnlyObservableCollection(new ObservableCollection(items)); } } -} \ No newline at end of file +} diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowVM.cs b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowVM.cs index bb4368201a..a8203a22a5 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowVM.cs +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindowVM.cs @@ -29,7 +29,7 @@ public sealed class MainWindowVm : IMainWindowVm public MainWindowVm() { - Quantities = ToReadOnly(Enum.GetValues(typeof(QuantityType)).Cast().Skip(1)); + Quantities = ToReadOnly(Quantity.Types); _units = new ObservableCollection(); Units = new ReadOnlyObservableCollection(_units); @@ -131,21 +131,25 @@ private void UpdateResult() { if (SelectedFromUnit == null || SelectedToUnit == null) return; - ToValue = Convert.ToDecimal(UnitsNet.UnitConverter.ConvertByName(FromValue, - SelectedQuantity.ToString(), - SelectedFromUnit.UnitEnumValue.ToString(), - SelectedToUnit.UnitEnumValue.ToString())); + double convertedValue = UnitsNet.UnitConverter.Convert(FromValue, + SelectedFromUnit.UnitEnumValue, + SelectedToUnit.UnitEnumValue); + + ToValue = Convert.ToDecimal(convertedValue); } - private void OnSelectedQuantity(QuantityType quantity) + private void OnSelectedQuantity(QuantityType quantityType) { + QuantityInfo quantityInfo = Quantity.GetInfo(quantityType); + _units.Clear(); - IEnumerable unitValues = UnitHelper.GetUnits(quantity); - foreach (object unitValue in unitValues) _units.Add(new UnitListItem(unitValue)); + foreach (Enum unitValue in quantityInfo.Units) + { + _units.Add(new UnitListItem(unitValue)); + } - SelectedQuantity = quantity; - SelectedFromUnit = Units.FirstOrDefault(); - SelectedToUnit = Units.Skip(1).FirstOrDefault() ?? SelectedFromUnit; // Try to pick a different to-unit + SelectedFromUnit = _units.FirstOrDefault(); + SelectedToUnit = _units.Skip(1).FirstOrDefault() ?? SelectedFromUnit; // Try to pick a different to-unit } private static ReadOnlyObservableCollection ToReadOnly(IEnumerable items) @@ -159,4 +163,4 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null) PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } -} \ No newline at end of file +} diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj index c8277e5abc..6a7b657f4c 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj @@ -73,7 +73,6 @@ MSBuild:Compile Designer - MSBuild:Compile diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitHelper.cs b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitHelper.cs deleted file mode 100644 index 73feb754b3..0000000000 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitHelper.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace UnitsNet.Samples.UnitConverter.Wpf -{ - /// - /// TODO Move me into the UnitsNet library. This will solve a pain point in generically enumerating units for a quantity. - /// - public static class UnitHelper - { - /// - /// Look up and cache all unit enum types once with reflection, such as LengthUnit and MassUnit. - /// - private static readonly Type[] UnitEnumTypes = - Assembly.GetAssembly(typeof(Length)).ExportedTypes.Where(t => t.IsEnum && t.Namespace == "UnitsNet.Units").ToArray(); - - public static IReadOnlyList GetUnits(QuantityType quantity) - { - // Ex: Find unit enum type UnitsNet.Units.LengthUnit from quantity enum name QuantityType.Length - Type unitEnumType = UnitEnumTypes.First(t => t.FullName == $"UnitsNet.Units.{quantity}Unit"); - return Enum.GetValues(unitEnumType).Cast().Skip(1).ToArray(); - } - } -} \ No newline at end of file diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitListItem.cs b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitListItem.cs index 897361a0b3..555fc3195d 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitListItem.cs +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitListItem.cs @@ -9,10 +9,10 @@ namespace UnitsNet.Samples.UnitConverter.Wpf /// public sealed class UnitListItem { - public UnitListItem(object val) + public UnitListItem(Enum val) { UnitEnumValue = val; - UnitEnumValueInt = (int) val; + UnitEnumValueInt = Convert.ToInt32(val); UnitEnumType = val.GetType(); Abbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(UnitEnumType, UnitEnumValueInt); @@ -20,7 +20,7 @@ public UnitListItem(object val) } public string Text { get; } - public object UnitEnumValue { get; } + public Enum UnitEnumValue { get; } public int UnitEnumValueInt { get; } public Type UnitEnumType { get; } public string Abbreviation { get; } diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Converters/EnumBindingSource.cs b/Samples/WpfMVVMSample/WpfMVVMSample/Converters/EnumBindingSource.cs index 02d87b7737..db5b223288 100644 --- a/Samples/WpfMVVMSample/WpfMVVMSample/Converters/EnumBindingSource.cs +++ b/Samples/WpfMVVMSample/WpfMVVMSample/Converters/EnumBindingSource.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Markup; namespace WpfMVVMSample.Converters @@ -13,10 +10,10 @@ public class EnumBindingSourceExtension : MarkupExtension private Type _enumType; private Type EnumType { - get { return this._enumType; } + get => _enumType; set { - if (value != this._enumType) + if (value != _enumType) { if (value != null) { @@ -26,27 +23,29 @@ private Type EnumType throw new ArgumentException("Type must be for an Enum."); } - this._enumType = value; + _enumType = value; } } } + // Instantiated by GUI + // ReSharper disable once UnusedMember.Global public EnumBindingSourceExtension() { } public EnumBindingSourceExtension(Type enumType) { - this.EnumType = enumType; + EnumType = enumType; } public override object ProvideValue(IServiceProvider serviceProvider) { - if (this._enumType== null) + if (_enumType== null) throw new InvalidOperationException("The EnumType must be specified."); - Type actualEnumType = Nullable.GetUnderlyingType(this._enumType) ?? this._enumType; - - //omits the first enum element, typically "undefined" - var enumValues = Enum.GetValues(actualEnumType).Cast().Skip(1); + Type actualEnumType = Nullable.GetUnderlyingType(_enumType) ?? _enumType; + + // Omits the first unit enum element, such as LengthUnit.Undefined + IEnumerable enumValues = Enum.GetValues(actualEnumType).Cast().Skip(1); return enumValues; } diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Converters/UnitToStringConverter.cs b/Samples/WpfMVVMSample/WpfMVVMSample/Converters/UnitToStringConverter.cs index d783152170..e1d5842eaf 100644 --- a/Samples/WpfMVVMSample/WpfMVVMSample/Converters/UnitToStringConverter.cs +++ b/Samples/WpfMVVMSample/WpfMVVMSample/Converters/UnitToStringConverter.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.Globalization; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -11,10 +12,10 @@ namespace WpfMVVMSample.Converters { - public class UnitToStringConverter :MarkupExtension, IValueConverter + public class UnitToStringConverter : MarkupExtension, IValueConverter { //http://www.thejoyofcode.com/WPF_Quick_Tip_Converters_as_MarkupExtensions.aspx - private SettingsManager _settings; + private readonly SettingsManager _settings; private static UnitToStringConverter _instance; public UnitToStringConverter() @@ -25,62 +26,51 @@ public UnitToStringConverter() } } - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var quantityType = value.GetType(); - var unitEnumType = quantityType.GetProperty("BaseUnit").PropertyType; - var unitEnumValue = _settings.GetDefaultUnit(unitEnumType); - var significantDigits = _settings.SignificantDigits; + if (!(value is IQuantity quantity)) + throw new ArgumentException("Expected value of type UnitsNet.IQuantity.", nameof(value)); + + Enum unitEnumValue = _settings.GetDefaultUnit(quantity.QuantityInfo.UnitType); + int significantDigits = _settings.SignificantDigits; - var quantityInUnit = - quantityType - .GetMethod("ToUnit", new[] {unitEnumType}) - .Invoke(value, new[] {unitEnumValue}); + IQuantity quantityInUnit = quantity.ToUnit(unitEnumValue); - var result = quantityType - .GetMethod("ToString", new[] {typeof(IFormatProvider), typeof(int)}) - .Invoke(quantityInUnit, new object[] {null, significantDigits}); + return quantityInUnit.ToString(null, significantDigits); - return result; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var unitEnumType = targetType.GetProperty("BaseUnit").PropertyType; - var unitEnumValue = _settings.GetDefaultUnit(unitEnumType); + if (!typeof(IQuantity).IsAssignableFrom(targetType)) + throw new ArgumentException("Expected targetType of type UnitsNet.IQuantity.", nameof(value)); - if ((string)value == "") return 0.0; - - double number; - if (double.TryParse((string)value, out number)) - return ParseDouble(targetType, number, unitEnumType, unitEnumValue); + if (value == null || + !(value is string valueString) || + string.IsNullOrWhiteSpace(valueString)) + { + return new ValidationResult(false, "Input is not valid. Expected a number or a string like \"1.5 kg\"."); + } try { - return ParseUnit(value, targetType); + // If input is just a number, use the configured default unit + if (double.TryParse(valueString, out double number)) + { + Type unitEnumType = Quantity.Infos.First(qi => qi.ValueType == targetType).UnitType; + Enum defaultUnit = _settings.GetDefaultUnit(unitEnumType); + return Quantity.From(number, defaultUnit); + } + + // Otherwise try to parse the string, such as "1.5 kg" + return Quantity.Parse(targetType, valueString); } catch (Exception e) { - return new ValidationResult(false, e.InnerException.Message); + return new ValidationResult(false, e.InnerException?.Message ?? e.Message); } } - - private static object ParseDouble(Type targetType, double number, Type unitEnumType, object unitEnumValue) - { - return targetType - .GetMethod("From", new[] { typeof(QuantityValue), unitEnumType }) - .Invoke(null, new object[] { (QuantityValue)number, unitEnumValue }); - } - - private static object ParseUnit(object value, Type targetType) - { - return targetType - .GetMethod("Parse", new[] { typeof(string) }) - .Invoke(null, new object[] { value }); - } - public override object ProvideValue(IServiceProvider serviceProvider) { return _instance ?? (_instance = new UnitToStringConverter()); diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Settings/SettingsManager.cs b/Samples/WpfMVVMSample/WpfMVVMSample/Settings/SettingsManager.cs index 9aa777ebf0..659865b724 100644 --- a/Samples/WpfMVVMSample/WpfMVVMSample/Settings/SettingsManager.cs +++ b/Samples/WpfMVVMSample/WpfMVVMSample/Settings/SettingsManager.cs @@ -1,27 +1,24 @@ using Prism.Mvvm; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnitsNet.Units; namespace WpfMVVMSample.Settings { public class SettingsManager : BindableBase { - private Dictionary> _defaultUnitProviders; + private readonly Dictionary> _defaultUnitProviders; public SettingsManager() { DefaultMassUnit = MassUnit.Kilogram; DefaultAccelerationUnit = AccelerationUnit.MeterPerSecondSquared; DefaultForceUnit = ForceUnit.Newton; - _defaultUnitProviders = new Dictionary> + _defaultUnitProviders = new Dictionary> { - {typeof(MassUnit),()=> this.DefaultMassUnit }, - {typeof(AccelerationUnit),()=> this.DefaultAccelerationUnit }, - {typeof(ForceUnit),()=> this.DefaultForceUnit }, + {typeof(MassUnit), () => DefaultMassUnit}, + {typeof(AccelerationUnit), () => DefaultAccelerationUnit}, + {typeof(ForceUnit), () => DefaultForceUnit}, }; } @@ -46,7 +43,7 @@ public ForceUnit DefaultForceUnit set { SetProperty(ref _defaultForceUnit, value); } } - public object GetDefaultUnit(Type unitType) + public Enum GetDefaultUnit(Type unitType) { if (_defaultUnitProviders.ContainsKey(unitType)) { diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs new file mode 100644 index 0000000000..a0a0124b9e --- /dev/null +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -0,0 +1,133 @@ +// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). +// https://github.com/angularsen/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +namespace UnitsNet.Tests +{ + public class QuantityInfoTest + { + [Fact] + public void Constructor_AssignsProperties() + { + var expectedZero = Length.FromCentimeters(10); + var expectedUnits = new Enum[] {LengthUnit.Centimeter, LengthUnit.Kilometer}; + var expectedBaseUnit = LengthUnit.Meter; + var expectedQuantityType = QuantityType.Length; + var expectedBaseDimensions = Length.BaseDimensions; + + var info = new QuantityInfo(expectedQuantityType, expectedUnits, expectedBaseUnit, expectedZero, expectedBaseDimensions); + + Assert.Equal(expectedZero, info.Zero); + Assert.Equal("Length", info.Name); + Assert.Equal(expectedUnits, info.Units); + Assert.Equal(expectedBaseUnit, info.BaseUnit); + Assert.Equal(new[]{"Centimeter", "Kilometer"}, info.UnitNames); + Assert.Equal(expectedQuantityType, info.QuantityType); + Assert.Equal(expectedBaseDimensions, info.BaseDimensions); + } + + [Fact] + public void GenericsConstructor_AssignsProperties() + { + var expectedZero = Length.FromCentimeters(10); + var expectedUnits = new[] {LengthUnit.Centimeter, LengthUnit.Kilometer}; + var expectedBaseUnit = LengthUnit.Meter; + var expectedQuantityType = QuantityType.Length; + var expectedBaseDimensions = Length.BaseDimensions; + + var info = new QuantityInfo(expectedQuantityType, expectedUnits, expectedBaseUnit, expectedZero, expectedBaseDimensions); + + Assert.Equal(expectedZero, info.Zero); + Assert.Equal("Length", info.Name); + Assert.Equal(expectedUnits, info.Units); + Assert.Equal(expectedBaseUnit, info.BaseUnit); + Assert.Equal(new[]{"Centimeter", "Kilometer"}, info.UnitNames); + Assert.Equal(expectedQuantityType, info.QuantityType); + Assert.Equal(expectedBaseDimensions, info.BaseDimensions); + } + + [Fact] + public void Constructor_GivenUndefinedAsQuantityType_ThrowsArgumentException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Undefined, new Enum[0], Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + } + + [Fact] + public void GenericsConstructor_GivenUndefinedAsQuantityType_ThrowsArgumentException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Undefined, Length.Units, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + } + + [Fact] + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + public void Constructor_GivenNullAsUnits_ThrowsArgumentNullException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Length, null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + } + + [Fact] + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + public void GenericsConstructor_GivenNullAsUnits_ThrowsArgumentNullException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Length, null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + } + + [Fact] + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Length, new Enum[0], null, Length.Zero, Length.BaseDimensions)); + } + + [Fact] + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Length, new Enum[0], Length.BaseUnit, null, Length.BaseDimensions)); + } + + [Fact] + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Length, Length.Units, Length.BaseUnit, null, Length.BaseDimensions)); + } + + [Fact] + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Length, new Enum[0], Length.BaseUnit, Length.Zero, null)); + } + + [Fact] + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + public void GenericsConstructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() + { + Assert.Throws(() => new QuantityInfo(QuantityType.Length, Length.Units, Length.BaseUnit, Length.Zero, null)); + } + } +} diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs new file mode 100644 index 0000000000..d5593f93ad --- /dev/null +++ b/UnitsNet.Tests/QuantityTest.cs @@ -0,0 +1,187 @@ +// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). +// https://github.com/angularsen/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Globalization; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +namespace UnitsNet.Tests +{ + public class QuantityTest + { + // Exclude Undefined value + private static readonly int QuantityCount = Enum.GetValues(typeof(QuantityType)).Length - 1; + + [Theory] + [InlineData(double.NaN)] + [InlineData(double.PositiveInfinity)] + [InlineData(double.NegativeInfinity)] + public void From_GivenNaNOrInfinity_ThrowsArgumentException(double value) + { + Assert.Throws(() => Quantity.From(value, LengthUnit.Centimeter)); + } + + [Theory] + [InlineData(double.NaN)] + [InlineData(double.PositiveInfinity)] + [InlineData(double.NegativeInfinity)] + public void TryFrom_GivenNaNOrInfinity_ReturnsFalseAndNullQuantity(double value) + { + Assert.False(Quantity.TryFrom(value, LengthUnit.Centimeter, out IQuantity parsedLength)); + Assert.Null(parsedLength); + } + + [Fact] + public void From_GivenValueAndUnit_ReturnsQuantity() + { + Assert.Equal(Length.FromCentimeters(3), Quantity.From(3, LengthUnit.Centimeter)); + Assert.Equal(Mass.FromTonnes(3), Quantity.From(3, MassUnit.Tonne)); + Assert.Equal(Pressure.FromMegabars(3), Quantity.From(3, PressureUnit.Megabar)); + } + + [Fact] + public void GetInfo_GivenLength_ReturnsQuantityInfoForLength() + { + var knownLengthUnits = new Enum[] {LengthUnit.Meter, LengthUnit.Centimeter, LengthUnit.Kilometer}; + var knownLengthUnitNames = new[] {"Meter", "Centimeter", "Kilometer"}; + var lengthUnitCount = Enum.GetValues(typeof(LengthUnit)).Length - 1; // Exclude LengthUnit.Undefined + + QuantityInfo quantityInfo = Quantity.GetInfo(QuantityType.Length); + + Assert.Equal("Length", quantityInfo.Name); + Assert.Equal(QuantityType.Length, quantityInfo.QuantityType); + Assert.Superset(knownLengthUnitNames.ToHashSet(), quantityInfo.UnitNames.ToHashSet()); + Assert.Superset(knownLengthUnits.ToHashSet(), quantityInfo.Units.ToHashSet()); + Assert.Equal(lengthUnitCount, quantityInfo.UnitNames.Length); + Assert.Equal(lengthUnitCount, quantityInfo.Units.Length); + Assert.Equal(typeof(LengthUnit), quantityInfo.UnitType); + Assert.Equal(typeof(Length), quantityInfo.ValueType); + Assert.Equal(Length.Zero, quantityInfo.Zero); + } + + [Fact] + public void GetInfo_GivenMass_ReturnsQuantityInfoForMass() + { + var knownMassUnits = new Enum[] {MassUnit.Kilogram, MassUnit.Gram, MassUnit.Tonne}; + var knownMassUnitNames = new[] {"Kilogram", "Gram", "Tonne"}; + var massUnitCount = Enum.GetValues(typeof(MassUnit)).Length - 1; // Exclude MassUnit.Undefined + + QuantityInfo quantityInfo = Quantity.GetInfo(QuantityType.Mass); + + Assert.Equal("Mass", quantityInfo.Name); + Assert.Equal(QuantityType.Mass, quantityInfo.QuantityType); + Assert.Superset(knownMassUnitNames.ToHashSet(), quantityInfo.UnitNames.ToHashSet()); + Assert.Superset(knownMassUnits.ToHashSet(), quantityInfo.Units.ToHashSet()); + Assert.Equal(massUnitCount, quantityInfo.UnitNames.Length); + Assert.Equal(massUnitCount, quantityInfo.Units.Length); + Assert.Equal(typeof(MassUnit), quantityInfo.UnitType); + Assert.Equal(typeof(Mass), quantityInfo.ValueType); + Assert.Equal(Mass.Zero, quantityInfo.Zero); + } + + [Fact] + public void Infos_ReturnsKnownQuantityInfoObjects() + { + var knownQuantityInfos = new[] + { + Quantity.GetInfo(QuantityType.Length), + Quantity.GetInfo(QuantityType.Force), + Quantity.GetInfo(QuantityType.Mass) + }; + + var infos = Quantity.Infos; + + Assert.Superset(knownQuantityInfos.ToHashSet(), infos.ToHashSet()); + Assert.Equal(QuantityCount, infos.Length); + } + + [Fact] + public void Parse_GivenValueAndUnit_ReturnsQuantity() + { + Assert.Equal(Length.FromCentimeters(3), Quantity.Parse(CultureInfo.InvariantCulture, typeof(Length), "3 cm")); + Assert.Equal(Mass.FromTonnes(3), Quantity.Parse(CultureInfo.InvariantCulture, typeof(Mass), "03t")); + Assert.Equal(Pressure.FromMegabars(3), Quantity.Parse(CultureInfo.InvariantCulture, typeof(Pressure), "3.0 Mbar")); + } + + [Fact] + public void QuantityNames_ReturnsKnownNames() + { + var knownNames = new[] {"Length", "Force", "Mass"}; + + var names = Quantity.Names; + + Assert.Superset(knownNames.ToHashSet(), names.ToHashSet()); + Assert.Equal(QuantityCount, names.Length); + } + + [Fact] + public void TryFrom_GivenValueAndUnit_ReturnsQuantity() + { + Assert.True(Quantity.TryFrom(3, LengthUnit.Centimeter, out IQuantity parsedLength)); + Assert.Equal(Length.FromCentimeters(3), parsedLength); + + Assert.True(Quantity.TryFrom(3, MassUnit.Tonne, out IQuantity parsedMass)); + Assert.Equal(Mass.FromTonnes(3), parsedMass); + + Assert.True(Quantity.TryFrom(3, PressureUnit.Megabar, out IQuantity parsedPressure)); + Assert.Equal(Pressure.FromMegabars(3), parsedPressure); + } + + [Fact] + public void TryParse_GivenInvalidString_ReturnsFalseAndNullQuantity() + { + Assert.False(Quantity.TryParse(typeof(Length), "x cm", out IQuantity parsedLength)); + Assert.Null(parsedLength); + + Assert.False(Quantity.TryParse(typeof(Mass), "xt", out IQuantity parsedMass)); + Assert.Null(parsedMass); + + Assert.False(Quantity.TryParse(typeof(Pressure), "foo", out IQuantity parsedPressure)); + Assert.Null(parsedPressure); + } + + [Fact] + public void TryParse_GivenValueAndUnit_ReturnsQuantity() + { + Assert.True(Quantity.TryParse(typeof(Length), "3 cm", out IQuantity parsedLength)); + Assert.Equal(Length.FromCentimeters(3), parsedLength); + + Assert.True(Quantity.TryParse(typeof(Mass), "03t", out IQuantity parsedMass)); + Assert.Equal(Mass.FromTonnes(3), parsedMass); + + Assert.True(Quantity.TryParse(typeof(Pressure), "3.0 Mbar", out IQuantity parsedPressure)); + Assert.Equal(Pressure.FromMegabars(3), parsedPressure); + } + + [Fact] + public void Types_ReturnsKnownQuantityTypes() + { + var knownQuantities = new[] {QuantityType.Length, QuantityType.Force, QuantityType.Mass}; + + var types = Quantity.Types; + + Assert.Superset(knownQuantities.ToHashSet(), types.ToHashSet()); + Assert.Equal(QuantityCount, types.Length); + } + } +} diff --git a/UnitsNet.Tests/QuantityTests.cs b/UnitsNet.Tests/QuantityTests.cs index cec7093e68..d0521745f5 100644 --- a/UnitsNet.Tests/QuantityTests.cs +++ b/UnitsNet.Tests/QuantityTests.cs @@ -1,16 +1,16 @@ // Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). // https://github.com/angularsen/UnitsNet -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -19,6 +19,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using System.Linq; using UnitsNet.Units; using Xunit; @@ -34,5 +35,36 @@ public void GetHashCodeForDifferentQuantitiesWithSameValuesAreNotEqual() Assert.NotEqual( length.GetHashCode(), area.GetHashCode() ); } + + [Fact] + public void Length_QuantityInfo_ReturnsQuantityInfoAboutLength() + { + var length = new Length(1, LengthUnit.Centimeter); + + QuantityInfo quantityInfo = length.QuantityInfo; + + AssertQuantityInfoRepresentsLength(quantityInfo); + } + + [Fact] + public void Length_Info_ReturnsQuantityInfoAboutLength() + { + QuantityInfo quantityInfo = Length.Info; + + AssertQuantityInfoRepresentsLength(quantityInfo); + } + + private static void AssertQuantityInfoRepresentsLength(QuantityInfo quantityInfo) + { + Assert.Equal(Length.Zero, quantityInfo.Zero); + Assert.Equal("Length", quantityInfo.Name); + + var lengthUnits = EnumUtils.GetEnumValues().Except(new[] {LengthUnit.Undefined}).ToArray(); + Assert.Equal(lengthUnits, quantityInfo.Units); + Assert.Equal(QuantityType.Length, quantityInfo.QuantityType); + + var lengthUnitNames = lengthUnits.Select(x => x.ToString()); + Assert.Equal(lengthUnitNames, quantityInfo.UnitNames); + } } } diff --git a/UnitsNet.Tests/UnitConverterTest.cs b/UnitsNet.Tests/UnitConverterTest.cs index 75ce44a1b6..5af66cbef3 100644 --- a/UnitsNet.Tests/UnitConverterTest.cs +++ b/UnitsNet.Tests/UnitConverterTest.cs @@ -1,16 +1,16 @@ // Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). // https://github.com/angularsen/UnitsNet -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -50,9 +50,9 @@ public void ConvertByName_UnitTypeCaseInsensitive() [Theory] [InlineData(1, "UnknownQuantity", "Meter", "Centimeter")] - public void ConvertByName_ThrowsQuantityNotFoundExceptionOnUnknownQuantity(double inputValue, string quantityTypeName, string fromUnit, string toUnit) + public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownQuantity(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.Throws(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); + Assert.Throws(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); } [Theory] @@ -132,4 +132,4 @@ public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(double Assert.Equal(expectedValue, result); } } -} \ No newline at end of file +} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.WindowsRuntimeComponent.g.cs index 94443bd88f..08f57cb762 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Acceleration : IQuantity static Acceleration() { BaseDimensions = new BaseDimensions(1, 0, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Acceleration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit MeterPerSecondSquared. @@ -98,6 +99,9 @@ private Acceleration(double numericValue, AccelerationUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Acceleration(double numericValue, AccelerationUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -643,6 +652,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((AccelerationUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.WindowsRuntimeComponent.g.cs index d12377f8cd..ab477ea159 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class AmountOfSubstance : IQuantity static AmountOfSubstance() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0); + Info = new QuantityInfo(QuantityType.AmountOfSubstance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Mole. @@ -98,6 +99,9 @@ private AmountOfSubstance(double numericValue, AmountOfSubstanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private AmountOfSubstance(double numericValue, AmountOfSubstanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AmountOfSubstanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -673,6 +682,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((AmountOfSubstanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.WindowsRuntimeComponent.g.cs index d21e5fc694..1b19e346c9 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class AmplitudeRatio : IQuantity static AmplitudeRatio() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.AmplitudeRatio, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit DecibelVolt. @@ -98,6 +99,9 @@ private AmplitudeRatio(double numericValue, AmplitudeRatioUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private AmplitudeRatio(double numericValue, AmplitudeRatioUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AmplitudeRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -508,6 +517,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((AmplitudeRatioUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.WindowsRuntimeComponent.g.cs index 3d9cf1e03d..26227b6896 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Angle : IQuantity static Angle() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.Angle, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Degree. @@ -98,6 +99,9 @@ private Angle(double numericValue, AngleUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Angle(double numericValue, AngleUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -658,6 +667,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((AngleUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.WindowsRuntimeComponent.g.cs index 4cc4e3372b..390ae19a53 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ApparentEnergy : IQuantity static ApparentEnergy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ApparentEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit VoltampereHour. @@ -98,6 +99,9 @@ private ApparentEnergy(double numericValue, ApparentEnergyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ApparentEnergy(double numericValue, ApparentEnergyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ApparentEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ApparentEnergyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.WindowsRuntimeComponent.g.cs index 688c067c0b..8f2c2c4be5 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ApparentPower : IQuantity static ApparentPower() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ApparentPower, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Voltampere. @@ -98,6 +99,9 @@ private ApparentPower(double numericValue, ApparentPowerUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ApparentPower(double numericValue, ApparentPowerUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ApparentPowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -508,6 +517,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ApparentPowerUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.WindowsRuntimeComponent.g.cs index fcbc55be4a..e1d7b01e00 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Area : IQuantity static Area() { BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Area, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit SquareMeter. @@ -98,6 +99,9 @@ private Area(double numericValue, AreaUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Area(double numericValue, AreaUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AreaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -643,6 +652,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((AreaUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.WindowsRuntimeComponent.g.cs index 3c0ed1599b..a8be923f84 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class AreaDensity : IQuantity static AreaDensity() { BaseDimensions = new BaseDimensions(-2, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.AreaDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit KilogramPerSquareMeter. @@ -98,6 +99,9 @@ private AreaDensity(double numericValue, AreaDensityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private AreaDensity(double numericValue, AreaDensityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AreaDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -463,6 +472,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((AreaDensityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.WindowsRuntimeComponent.g.cs index 80f4284676..13bba944ea 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class AreaMomentOfInertia : IQuantity static AreaMomentOfInertia() { BaseDimensions = new BaseDimensions(4, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.AreaMomentOfInertia, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit MeterToTheFourth. @@ -98,6 +99,9 @@ private AreaMomentOfInertia(double numericValue, AreaMomentOfInertiaUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private AreaMomentOfInertia(double numericValue, AreaMomentOfInertiaUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AreaMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -538,6 +547,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((AreaMomentOfInertiaUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.WindowsRuntimeComponent.g.cs index 2c1d25a564..1c491a0427 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class BitRate : IQuantity static BitRate() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.BitRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit BitPerSecond. @@ -101,6 +102,9 @@ private BitRate(decimal numericValue, BitRateUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private BitRate(decimal numericValue, BitRateUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public BitRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -841,6 +850,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((BitRateUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.WindowsRuntimeComponent.g.cs index 131983f29c..63577de814 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class BrakeSpecificFuelConsumption : IQuantity static BrakeSpecificFuelConsumption() { BaseDimensions = new BaseDimensions(-2, 0, 2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.BrakeSpecificFuelConsumption, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit KilogramPerJoule. @@ -98,6 +99,9 @@ private BrakeSpecificFuelConsumption(double numericValue, BrakeSpecificFuelConsu #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private BrakeSpecificFuelConsumption(double numericValue, BrakeSpecificFuelConsu /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public BrakeSpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((BrakeSpecificFuelConsumptionUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.WindowsRuntimeComponent.g.cs index 5a8f365de0..d445ff36ac 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Capacitance : IQuantity static Capacitance() { BaseDimensions = new BaseDimensions(-2, -1, 4, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Capacitance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Farad. @@ -101,6 +102,9 @@ private Capacitance(double numericValue, CapacitanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Capacitance(double numericValue, CapacitanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public CapacitanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -556,6 +565,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((CapacitanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.WindowsRuntimeComponent.g.cs index 4902ecaf69..3ed7417b39 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class CoefficientOfThermalExpansion : IQuantity static CoefficientOfThermalExpansion() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.CoefficientOfThermalExpansion, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit InverseKelvin. @@ -98,6 +99,9 @@ private CoefficientOfThermalExpansion(double numericValue, CoefficientOfThermalE #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private CoefficientOfThermalExpansion(double numericValue, CoefficientOfThermalE /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public CoefficientOfThermalExpansionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((CoefficientOfThermalExpansionUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs index 2c40ddcdb0..cc3d021307 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Density : IQuantity static Density() { BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Density, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit KilogramPerCubicMeter. @@ -101,6 +102,9 @@ private Density(double numericValue, DensityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Density(double numericValue, DensityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public DensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1036,6 +1045,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((DensityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.WindowsRuntimeComponent.g.cs index 8efdc33abc..a8f79b1e2c 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Duration : IQuantity static Duration() { BaseDimensions = new BaseDimensions(0, 0, 1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Duration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Second. @@ -98,6 +99,9 @@ private Duration(double numericValue, DurationUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Duration(double numericValue, DurationUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public DurationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -598,6 +607,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((DurationUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.WindowsRuntimeComponent.g.cs index 10692d435a..50bb51042c 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class DynamicViscosity : IQuantity static DynamicViscosity() { BaseDimensions = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.DynamicViscosity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit NewtonSecondPerMeterSquared. @@ -101,6 +102,9 @@ private DynamicViscosity(double numericValue, DynamicViscosityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private DynamicViscosity(double numericValue, DynamicViscosityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public DynamicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -541,6 +550,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((DynamicViscosityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.WindowsRuntimeComponent.g.cs index f76c280ffe..c9bf26be0e 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ElectricAdmittance : IQuantity static ElectricAdmittance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricAdmittance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Siemens. @@ -98,6 +99,9 @@ private ElectricAdmittance(double numericValue, ElectricAdmittanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ElectricAdmittance(double numericValue, ElectricAdmittanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricAdmittanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -508,6 +517,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricAdmittanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.WindowsRuntimeComponent.g.cs index 0b97812a5e..77bf1358bf 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricCharge : IQuantity static ElectricCharge() { BaseDimensions = new BaseDimensions(0, 0, 1, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricCharge, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Coulomb. @@ -101,6 +102,9 @@ private ElectricCharge(double numericValue, ElectricChargeUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricCharge(double numericValue, ElectricChargeUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricChargeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricChargeUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.WindowsRuntimeComponent.g.cs index a72d719df7..827946f8b4 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricChargeDensity : IQuantity static ElectricChargeDensity() { BaseDimensions = new BaseDimensions(-3, 0, 1, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricChargeDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit CoulombPerCubicMeter. @@ -101,6 +102,9 @@ private ElectricChargeDensity(double numericValue, ElectricChargeDensityUnit uni #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricChargeDensity(double numericValue, ElectricChargeDensityUnit uni /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricChargeDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricChargeDensityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.WindowsRuntimeComponent.g.cs index 9b2353aa76..d2d87b54cc 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricConductance : IQuantity static ElectricConductance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricConductance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Siemens. @@ -101,6 +102,9 @@ private ElectricConductance(double numericValue, ElectricConductanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricConductance(double numericValue, ElectricConductanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricConductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -496,6 +505,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricConductanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.WindowsRuntimeComponent.g.cs index d463e98045..d250c836b8 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricConductivity : IQuantity static ElectricConductivity() { BaseDimensions = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricConductivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit SiemensPerMeter. @@ -101,6 +102,9 @@ private ElectricConductivity(double numericValue, ElectricConductivityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricConductivity(double numericValue, ElectricConductivityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricConductivityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.WindowsRuntimeComponent.g.cs index 03021b033b..959579febb 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ElectricCurrent : IQuantity static ElectricCurrent() { BaseDimensions = new BaseDimensions(0, 0, 0, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricCurrent, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Ampere. @@ -98,6 +99,9 @@ private ElectricCurrent(double numericValue, ElectricCurrentUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ElectricCurrent(double numericValue, ElectricCurrentUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricCurrentUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -568,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricCurrentUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.WindowsRuntimeComponent.g.cs index 947625b277..63be2d2ddc 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricCurrentDensity : IQuantity static ElectricCurrentDensity() { BaseDimensions = new BaseDimensions(-2, 0, 0, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricCurrentDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit AmperePerSquareMeter. @@ -101,6 +102,9 @@ private ElectricCurrentDensity(double numericValue, ElectricCurrentDensityUnit u #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricCurrentDensity(double numericValue, ElectricCurrentDensityUnit u /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricCurrentDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricCurrentDensityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.WindowsRuntimeComponent.g.cs index 5bf58fa07e..33000fe1ba 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ElectricCurrentGradient : IQuantity static ElectricCurrentGradient() { BaseDimensions = new BaseDimensions(0, 0, -1, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricCurrentGradient, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit AmperePerSecond. @@ -98,6 +99,9 @@ private ElectricCurrentGradient(double numericValue, ElectricCurrentGradientUnit #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ElectricCurrentGradient(double numericValue, ElectricCurrentGradientUnit /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricCurrentGradientUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -463,6 +472,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricCurrentGradientUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.WindowsRuntimeComponent.g.cs index db0428419f..844c64b25d 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricField : IQuantity static ElectricField() { BaseDimensions = new BaseDimensions(1, 1, -3, -1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricField, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit VoltPerMeter. @@ -101,6 +102,9 @@ private ElectricField(double numericValue, ElectricFieldUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricField(double numericValue, ElectricFieldUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricFieldUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.WindowsRuntimeComponent.g.cs index ad3717ead6..e3c4912972 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricInductance : IQuantity static ElectricInductance() { BaseDimensions = new BaseDimensions(2, 1, -2, -2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricInductance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Henry. @@ -101,6 +102,9 @@ private ElectricInductance(double numericValue, ElectricInductanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricInductance(double numericValue, ElectricInductanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricInductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -511,6 +520,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricInductanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.WindowsRuntimeComponent.g.cs index 438a68a7fe..b72cd51609 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ElectricPotential : IQuantity static ElectricPotential() { BaseDimensions = new BaseDimensions(2, 1, -3, -1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricPotential, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Volt. @@ -98,6 +99,9 @@ private ElectricPotential(double numericValue, ElectricPotentialUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ElectricPotential(double numericValue, ElectricPotentialUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricPotentialUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -523,6 +532,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricPotentialUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.WindowsRuntimeComponent.g.cs index 8c934c4ea6..9db5653f18 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ElectricPotentialAc : IQuantity static ElectricPotentialAc() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.ElectricPotentialAc, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit VoltAc. @@ -98,6 +99,9 @@ private ElectricPotentialAc(double numericValue, ElectricPotentialAcUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ElectricPotentialAc(double numericValue, ElectricPotentialAcUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricPotentialAcUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -523,6 +532,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricPotentialAcUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.WindowsRuntimeComponent.g.cs index 4752150d04..402f18a4b5 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ElectricPotentialDc : IQuantity static ElectricPotentialDc() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.ElectricPotentialDc, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit VoltDc. @@ -98,6 +99,9 @@ private ElectricPotentialDc(double numericValue, ElectricPotentialDcUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ElectricPotentialDc(double numericValue, ElectricPotentialDcUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricPotentialDcUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -523,6 +532,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricPotentialDcUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.WindowsRuntimeComponent.g.cs index f9734c9e9b..5d58571ed2 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ElectricResistance : IQuantity static ElectricResistance() { BaseDimensions = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricResistance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Ohm. @@ -98,6 +99,9 @@ private ElectricResistance(double numericValue, ElectricResistanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ElectricResistance(double numericValue, ElectricResistanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -523,6 +532,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricResistanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.WindowsRuntimeComponent.g.cs index da7f2187cb..111976cce3 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ElectricResistivity : IQuantity static ElectricResistivity() { BaseDimensions = new BaseDimensions(3, 1, -3, -2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricResistivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit OhmMeter. @@ -101,6 +102,9 @@ private ElectricResistivity(double numericValue, ElectricResistivityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ElectricResistivity(double numericValue, ElectricResistivityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricResistivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -661,6 +670,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ElectricResistivityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.WindowsRuntimeComponent.g.cs index 17cf032399..2e6350f72e 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Energy : IQuantity static Energy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Energy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Joule. @@ -98,6 +99,9 @@ private Energy(double numericValue, EnergyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Energy(double numericValue, EnergyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public EnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -778,6 +787,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((EnergyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.WindowsRuntimeComponent.g.cs index ef0f26a47a..b007d5a46a 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Entropy : IQuantity static Entropy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.Entropy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit JoulePerKelvin. @@ -98,6 +99,9 @@ private Entropy(double numericValue, EntropyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Entropy(double numericValue, EntropyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public EntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -553,6 +562,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((EntropyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.WindowsRuntimeComponent.g.cs index 389158cd90..b4d5d7b3fa 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Force : IQuantity static Force() { BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Force, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Newton. @@ -98,6 +99,9 @@ private Force(double numericValue, ForceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Force(double numericValue, ForceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ForceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -643,6 +652,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ForceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.WindowsRuntimeComponent.g.cs index 6ae9f79fc4..520985c5b1 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ForceChangeRate : IQuantity static ForceChangeRate() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ForceChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit NewtonPerSecond. @@ -98,6 +99,9 @@ private ForceChangeRate(double numericValue, ForceChangeRateUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ForceChangeRate(double numericValue, ForceChangeRateUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ForceChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -613,6 +622,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ForceChangeRateUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.WindowsRuntimeComponent.g.cs index cb16d22827..f6ebfbf655 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ForcePerLength : IQuantity static ForcePerLength() { BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ForcePerLength, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit NewtonPerMeter. @@ -98,6 +99,9 @@ private ForcePerLength(double numericValue, ForcePerLengthUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ForcePerLength(double numericValue, ForcePerLengthUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ForcePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -583,6 +592,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ForcePerLengthUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.WindowsRuntimeComponent.g.cs index a7378ba6cc..6e028b8fe7 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Frequency : IQuantity static Frequency() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Frequency, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Hertz. @@ -98,6 +99,9 @@ private Frequency(double numericValue, FrequencyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Frequency(double numericValue, FrequencyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public FrequencyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -568,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((FrequencyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.WindowsRuntimeComponent.g.cs index 69a30764ff..4419bc6b87 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class HeatFlux : IQuantity static HeatFlux() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.HeatFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit WattPerSquareMeter. @@ -98,6 +99,9 @@ private HeatFlux(double numericValue, HeatFluxUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private HeatFlux(double numericValue, HeatFluxUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public HeatFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -718,6 +727,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((HeatFluxUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.WindowsRuntimeComponent.g.cs index d939b00b16..cce8f794b0 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class HeatTransferCoefficient : IQuantity static HeatTransferCoefficient() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.HeatTransferCoefficient, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit WattPerSquareMeterKelvin. @@ -98,6 +99,9 @@ private HeatTransferCoefficient(double numericValue, HeatTransferCoefficientUnit #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private HeatTransferCoefficient(double numericValue, HeatTransferCoefficientUnit /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public HeatTransferCoefficientUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -478,6 +487,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((HeatTransferCoefficientUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.WindowsRuntimeComponent.g.cs index db8d457c27..babc32c9e9 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Illuminance : IQuantity static Illuminance() { BaseDimensions = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1); + Info = new QuantityInfo(QuantityType.Illuminance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Lux. @@ -101,6 +102,9 @@ private Illuminance(double numericValue, IlluminanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Illuminance(double numericValue, IlluminanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public IlluminanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -511,6 +520,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((IlluminanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.WindowsRuntimeComponent.g.cs index 22455abe25..d45c12c6c3 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Information : IQuantity static Information() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.Information, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Bit. @@ -98,6 +99,9 @@ private Information(decimal numericValue, InformationUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Information(decimal numericValue, InformationUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public InformationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -838,6 +847,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((InformationUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.WindowsRuntimeComponent.g.cs index e8bc9ba2cb..445be64d67 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Irradiance : IQuantity static Irradiance() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Irradiance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit WattPerSquareMeter. @@ -98,6 +99,9 @@ private Irradiance(double numericValue, IrradianceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Irradiance(double numericValue, IrradianceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public IrradianceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -658,6 +667,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((IrradianceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.WindowsRuntimeComponent.g.cs index ac31b948fa..2050069d52 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Irradiation : IQuantity static Irradiation() { BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Irradiation, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit JoulePerSquareMeter. @@ -101,6 +102,9 @@ private Irradiation(double numericValue, IrradiationUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Irradiation(double numericValue, IrradiationUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public IrradiationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -511,6 +520,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((IrradiationUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.WindowsRuntimeComponent.g.cs index 850806d6d3..fd88a5a316 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class KinematicViscosity : IQuantity static KinematicViscosity() { BaseDimensions = new BaseDimensions(2, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.KinematicViscosity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit SquareMeterPerSecond. @@ -101,6 +102,9 @@ private KinematicViscosity(double numericValue, KinematicViscosityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private KinematicViscosity(double numericValue, KinematicViscosityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public KinematicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -571,6 +580,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((KinematicViscosityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.WindowsRuntimeComponent.g.cs index c06e9e8ff7..35ceb88570 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class LapseRate : IQuantity static LapseRate() { BaseDimensions = new BaseDimensions(-1, 0, 0, 0, 1, 0, 0); + Info = new QuantityInfo(QuantityType.LapseRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit DegreeCelsiusPerKilometer. @@ -98,6 +99,9 @@ private LapseRate(double numericValue, LapseRateUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private LapseRate(double numericValue, LapseRateUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LapseRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -463,6 +472,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((LapseRateUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.WindowsRuntimeComponent.g.cs index 27c0b1b62e..c7973e5122 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Length : IQuantity static Length() { BaseDimensions = new BaseDimensions(1, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Length, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Meter. @@ -98,6 +99,9 @@ private Length(double numericValue, LengthUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Length(double numericValue, LengthUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -778,6 +787,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((LengthUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.WindowsRuntimeComponent.g.cs index 15753301fa..1eb64edd57 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Level : IQuantity static Level() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.Level, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Decibel. @@ -98,6 +99,9 @@ private Level(double numericValue, LevelUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Level(double numericValue, LevelUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LevelUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -478,6 +487,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((LevelUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.WindowsRuntimeComponent.g.cs index d363005ee2..d31eea0a62 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class LinearDensity : IQuantity static LinearDensity() { BaseDimensions = new BaseDimensions(-1, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.LinearDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit KilogramPerMeter. @@ -101,6 +102,9 @@ private LinearDensity(double numericValue, LinearDensityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private LinearDensity(double numericValue, LinearDensityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LinearDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -496,6 +505,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((LinearDensityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.WindowsRuntimeComponent.g.cs index 7ccd8f8ef4..cf67c8c400 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class LuminousFlux : IQuantity static LuminousFlux() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); + Info = new QuantityInfo(QuantityType.LuminousFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Lumen. @@ -101,6 +102,9 @@ private LuminousFlux(double numericValue, LuminousFluxUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private LuminousFlux(double numericValue, LuminousFluxUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LuminousFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((LuminousFluxUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.WindowsRuntimeComponent.g.cs index 0852f82a46..fc0f3fcaae 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class LuminousIntensity : IQuantity static LuminousIntensity() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); + Info = new QuantityInfo(QuantityType.LuminousIntensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Candela. @@ -101,6 +102,9 @@ private LuminousIntensity(double numericValue, LuminousIntensityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private LuminousIntensity(double numericValue, LuminousIntensityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LuminousIntensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((LuminousIntensityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.WindowsRuntimeComponent.g.cs index aa2a621aa7..0c5065cf67 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class MagneticField : IQuantity static MagneticField() { BaseDimensions = new BaseDimensions(0, 1, -2, -1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MagneticField, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Tesla. @@ -101,6 +102,9 @@ private MagneticField(double numericValue, MagneticFieldUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private MagneticField(double numericValue, MagneticFieldUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MagneticFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -511,6 +520,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MagneticFieldUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.WindowsRuntimeComponent.g.cs index 4d9a704788..9d896dbfb8 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class MagneticFlux : IQuantity static MagneticFlux() { BaseDimensions = new BaseDimensions(2, 1, -2, -1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MagneticFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Weber. @@ -101,6 +102,9 @@ private MagneticFlux(double numericValue, MagneticFluxUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private MagneticFlux(double numericValue, MagneticFluxUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MagneticFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MagneticFluxUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.WindowsRuntimeComponent.g.cs index 4291d2a12e..f210e84292 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Magnetization : IQuantity static Magnetization() { BaseDimensions = new BaseDimensions(-1, 0, 0, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Magnetization, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit AmperePerMeter. @@ -101,6 +102,9 @@ private Magnetization(double numericValue, MagnetizationUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Magnetization(double numericValue, MagnetizationUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MagnetizationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MagnetizationUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs index fba18671c9..a4c128811a 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Mass : IQuantity static Mass() { BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Mass, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Kilogram. @@ -98,6 +99,9 @@ private Mass(double numericValue, MassUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Mass(double numericValue, MassUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -793,6 +802,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MassUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.WindowsRuntimeComponent.g.cs index 69e0f0b145..987d910866 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class MassFlow : IQuantity static MassFlow() { BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MassFlow, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit GramPerSecond. @@ -98,6 +99,9 @@ private MassFlow(double numericValue, MassFlowUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private MassFlow(double numericValue, MassFlowUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -913,6 +922,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MassFlowUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.WindowsRuntimeComponent.g.cs index 33d9390752..14957f2075 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class MassFlux : IQuantity static MassFlux() { BaseDimensions = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MassFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit KilogramPerSecondPerSquareMeter. @@ -98,6 +99,9 @@ private MassFlux(double numericValue, MassFluxUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private MassFlux(double numericValue, MassFluxUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -478,6 +487,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MassFluxUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.WindowsRuntimeComponent.g.cs index 893be9d39d..1f74cb4ce4 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class MassMomentOfInertia : IQuantity static MassMomentOfInertia() { BaseDimensions = new BaseDimensions(2, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MassMomentOfInertia, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit KilogramSquareMeter. @@ -98,6 +99,9 @@ private MassMomentOfInertia(double numericValue, MassMomentOfInertiaUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private MassMomentOfInertia(double numericValue, MassMomentOfInertiaUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -868,6 +877,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MassMomentOfInertiaUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.WindowsRuntimeComponent.g.cs index b67a6bb2eb..401cb0aba3 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class MolarEnergy : IQuantity static MolarEnergy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, -1, 0); + Info = new QuantityInfo(QuantityType.MolarEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit JoulePerMole. @@ -98,6 +99,9 @@ private MolarEnergy(double numericValue, MolarEnergyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private MolarEnergy(double numericValue, MolarEnergyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MolarEnergyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.WindowsRuntimeComponent.g.cs index 147d033aae..2d2a4236ca 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class MolarEntropy : IQuantity static MolarEntropy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, -1, 0); + Info = new QuantityInfo(QuantityType.MolarEntropy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit JoulePerMoleKelvin. @@ -98,6 +99,9 @@ private MolarEntropy(double numericValue, MolarEntropyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private MolarEntropy(double numericValue, MolarEntropyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MolarEntropyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.WindowsRuntimeComponent.g.cs index 90b42e3281..72d37e1b2c 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class MolarMass : IQuantity static MolarMass() { BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, -1, 0); + Info = new QuantityInfo(QuantityType.MolarMass, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit KilogramPerMole. @@ -98,6 +99,9 @@ private MolarMass(double numericValue, MolarMassUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private MolarMass(double numericValue, MolarMassUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarMassUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -628,6 +637,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MolarMassUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.WindowsRuntimeComponent.g.cs index b7be810adf..847c2d8cd0 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Molarity : IQuantity static Molarity() { BaseDimensions = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0); + Info = new QuantityInfo(QuantityType.Molarity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit MolesPerCubicMeter. @@ -101,6 +102,9 @@ private Molarity(double numericValue, MolarityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Molarity(double numericValue, MolarityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -571,6 +580,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((MolarityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.WindowsRuntimeComponent.g.cs index 512fe996d8..23d96bbe1a 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Permeability : IQuantity static Permeability() { BaseDimensions = new BaseDimensions(1, 1, -2, -2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Permeability, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit HenryPerMeter. @@ -101,6 +102,9 @@ private Permeability(double numericValue, PermeabilityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Permeability(double numericValue, PermeabilityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PermeabilityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((PermeabilityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.WindowsRuntimeComponent.g.cs index 19ee1e46b7..0e15153f08 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class Permittivity : IQuantity static Permittivity() { BaseDimensions = new BaseDimensions(-3, -1, 4, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Permittivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit FaradPerMeter. @@ -101,6 +102,9 @@ private Permittivity(double numericValue, PermittivityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private Permittivity(double numericValue, PermittivityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PermittivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((PermittivityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.WindowsRuntimeComponent.g.cs index 53d06b9af2..c41560c5d3 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Power : IQuantity static Power() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Power, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Watt. @@ -98,6 +99,9 @@ private Power(decimal numericValue, PowerUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Power(decimal numericValue, PowerUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -748,6 +757,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((PowerUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.WindowsRuntimeComponent.g.cs index 49230b2271..8575a58e79 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class PowerDensity : IQuantity static PowerDensity() { BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.PowerDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit WattPerCubicMeter. @@ -98,6 +99,9 @@ private PowerDensity(double numericValue, PowerDensityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private PowerDensity(double numericValue, PowerDensityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PowerDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1108,6 +1117,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((PowerDensityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.WindowsRuntimeComponent.g.cs index 379026875a..2dca1d2d03 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class PowerRatio : IQuantity static PowerRatio() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.PowerRatio, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit DecibelWatt. @@ -98,6 +99,9 @@ private PowerRatio(double numericValue, PowerRatioUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private PowerRatio(double numericValue, PowerRatioUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PowerRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -478,6 +487,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((PowerRatioUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.WindowsRuntimeComponent.g.cs index f22554a681..a133a71e82 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Pressure : IQuantity static Pressure() { BaseDimensions = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Pressure, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Pascal. @@ -98,6 +99,9 @@ private Pressure(double numericValue, PressureUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Pressure(double numericValue, PressureUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PressureUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1078,6 +1087,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((PressureUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.WindowsRuntimeComponent.g.cs index 945ea331e7..f0baf28104 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class PressureChangeRate : IQuantity static PressureChangeRate() { BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.PressureChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit PascalPerSecond. @@ -98,6 +99,9 @@ private PressureChangeRate(double numericValue, PressureChangeRateUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private PressureChangeRate(double numericValue, PressureChangeRateUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PressureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -553,6 +562,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((PressureChangeRateUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.WindowsRuntimeComponent.g.cs index 851524fe9d..5f0c10a334 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Ratio : IQuantity static Ratio() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.Ratio, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit DecimalFraction. @@ -98,6 +99,9 @@ private Ratio(double numericValue, RatioUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Ratio(double numericValue, RatioUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -538,6 +547,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((RatioUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.WindowsRuntimeComponent.g.cs index 69d606ef62..daed0a599a 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ReactiveEnergy : IQuantity static ReactiveEnergy() { BaseDimensions = new BaseDimensions(2, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ReactiveEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit VoltampereReactiveHour. @@ -98,6 +99,9 @@ private ReactiveEnergy(double numericValue, ReactiveEnergyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ReactiveEnergy(double numericValue, ReactiveEnergyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ReactiveEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ReactiveEnergyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.WindowsRuntimeComponent.g.cs index ae479bc556..2653aab6dc 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ReactivePower : IQuantity static ReactivePower() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ReactivePower, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit VoltampereReactive. @@ -98,6 +99,9 @@ private ReactivePower(double numericValue, ReactivePowerUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ReactivePower(double numericValue, ReactivePowerUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ReactivePowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -508,6 +517,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ReactivePowerUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.WindowsRuntimeComponent.g.cs index c8b80cb06d..ac5c2b4f1b 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class RotationalAcceleration : IQuantity static RotationalAcceleration() { BaseDimensions = new BaseDimensions(0, 0, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.RotationalAcceleration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit RadianPerSecondSquared. @@ -98,6 +99,9 @@ private RotationalAcceleration(double numericValue, RotationalAccelerationUnit u #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private RotationalAcceleration(double numericValue, RotationalAccelerationUnit u /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalAccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((RotationalAccelerationUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.WindowsRuntimeComponent.g.cs index 7dfdd3637c..30219a5001 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class RotationalSpeed : IQuantity static RotationalSpeed() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.RotationalSpeed, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit RadianPerSecond. @@ -98,6 +99,9 @@ private RotationalSpeed(double numericValue, RotationalSpeedUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private RotationalSpeed(double numericValue, RotationalSpeedUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalSpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -643,6 +652,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((RotationalSpeedUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.WindowsRuntimeComponent.g.cs index c85dc7c89a..814f4e4d8d 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class RotationalStiffness : IQuantity static RotationalStiffness() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.RotationalStiffness, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit NewtonMeterPerRadian. @@ -98,6 +99,9 @@ private RotationalStiffness(double numericValue, RotationalStiffnessUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private RotationalStiffness(double numericValue, RotationalStiffnessUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalStiffnessUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((RotationalStiffnessUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.WindowsRuntimeComponent.g.cs index 977440ed79..c82828bfa5 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class RotationalStiffnessPerLength : IQuantity static RotationalStiffnessPerLength() { BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.RotationalStiffnessPerLength, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit NewtonMeterPerRadianPerMeter. @@ -98,6 +99,9 @@ private RotationalStiffnessPerLength(double numericValue, RotationalStiffnessPer #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private RotationalStiffnessPerLength(double numericValue, RotationalStiffnessPer /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalStiffnessPerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((RotationalStiffnessPerLengthUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.WindowsRuntimeComponent.g.cs index d2a27d85c9..ffe3b92393 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class SolidAngle : IQuantity static SolidAngle() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.SolidAngle, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Steradian. @@ -101,6 +102,9 @@ private SolidAngle(double numericValue, SolidAngleUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private SolidAngle(double numericValue, SolidAngleUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SolidAngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -466,6 +475,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((SolidAngleUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs index 3703e3b3c9..e2f16162b0 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class SpecificEnergy : IQuantity static SpecificEnergy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit JoulePerKilogram. @@ -101,6 +102,9 @@ private SpecificEnergy(double numericValue, SpecificEnergyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private SpecificEnergy(double numericValue, SpecificEnergyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -586,6 +595,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((SpecificEnergyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.WindowsRuntimeComponent.g.cs index 60cad92d7c..ce8c7c1ff9 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class SpecificEntropy : IQuantity static SpecificEntropy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificEntropy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit JoulePerKilogramKelvin. @@ -98,6 +99,9 @@ private SpecificEntropy(double numericValue, SpecificEntropyUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private SpecificEntropy(double numericValue, SpecificEntropyUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -568,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((SpecificEntropyUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.WindowsRuntimeComponent.g.cs index f9a0d75ea9..c81b3663b1 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class SpecificVolume : IQuantity static SpecificVolume() { BaseDimensions = new BaseDimensions(3, -1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificVolume, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit CubicMeterPerKilogram. @@ -98,6 +99,9 @@ private SpecificVolume(double numericValue, SpecificVolumeUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private SpecificVolume(double numericValue, SpecificVolumeUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificVolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -493,6 +502,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((SpecificVolumeUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.WindowsRuntimeComponent.g.cs index bedc38f78a..22f85c0db9 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class SpecificWeight : IQuantity static SpecificWeight() { BaseDimensions = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificWeight, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit NewtonPerCubicMeter. @@ -101,6 +102,9 @@ private SpecificWeight(double numericValue, SpecificWeightUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private SpecificWeight(double numericValue, SpecificWeightUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificWeightUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -706,6 +715,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((SpecificWeightUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.WindowsRuntimeComponent.g.cs index 76cb7ebae1..7595102c52 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Speed : IQuantity static Speed() { BaseDimensions = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Speed, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit MeterPerSecond. @@ -98,6 +99,9 @@ private Speed(double numericValue, SpeedUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Speed(double numericValue, SpeedUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -928,6 +937,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((SpeedUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.WindowsRuntimeComponent.g.cs index 69093d925a..c8863b52d6 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Temperature : IQuantity static Temperature() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); + Info = new QuantityInfo(QuantityType.Temperature, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Kelvin. @@ -98,6 +99,9 @@ private Temperature(double numericValue, TemperatureUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Temperature(double numericValue, TemperatureUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TemperatureUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -568,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((TemperatureUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.WindowsRuntimeComponent.g.cs index b3c5128afa..d6726bb8a6 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class TemperatureChangeRate : IQuantity static TemperatureChangeRate() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 1, 0, 0); + Info = new QuantityInfo(QuantityType.TemperatureChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit DegreeCelsiusPerSecond. @@ -98,6 +99,9 @@ private TemperatureChangeRate(double numericValue, TemperatureChangeRateUnit uni #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private TemperatureChangeRate(double numericValue, TemperatureChangeRateUnit uni /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TemperatureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -598,6 +607,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((TemperatureChangeRateUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.WindowsRuntimeComponent.g.cs index a29737d0c5..65354a33eb 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class TemperatureDelta : IQuantity static TemperatureDelta() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.TemperatureDelta, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit Kelvin. @@ -98,6 +99,9 @@ private TemperatureDelta(double numericValue, TemperatureDeltaUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private TemperatureDelta(double numericValue, TemperatureDeltaUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TemperatureDeltaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -568,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((TemperatureDeltaUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.WindowsRuntimeComponent.g.cs index ebc1d99a6b..7490a60cfe 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.WindowsRuntimeComponent.g.cs @@ -70,6 +70,7 @@ public sealed partial class ThermalConductivity : IQuantity static ThermalConductivity() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.ThermalConductivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit WattPerMeterKelvin. @@ -101,6 +102,9 @@ private ThermalConductivity(double numericValue, ThermalConductivityUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -145,11 +149,16 @@ private ThermalConductivity(double numericValue, ThermalConductivityUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ThermalConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -481,6 +490,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ThermalConductivityUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.WindowsRuntimeComponent.g.cs index eb7d660fdb..67a1f6e093 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class ThermalResistance : IQuantity static ThermalResistance() { BaseDimensions = new BaseDimensions(0, -1, 3, 0, 1, 0, 0); + Info = new QuantityInfo(QuantityType.ThermalResistance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit SquareMeterKelvinPerKilowatt. @@ -98,6 +99,9 @@ private ThermalResistance(double numericValue, ThermalResistanceUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private ThermalResistance(double numericValue, ThermalResistanceUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ThermalResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -523,6 +532,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((ThermalResistanceUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.WindowsRuntimeComponent.g.cs index c0d5902656..20916a4b26 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Torque : IQuantity static Torque() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Torque, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit NewtonMeter. @@ -98,6 +99,9 @@ private Torque(double numericValue, TorqueUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Torque(double numericValue, TorqueUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TorqueUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -763,6 +772,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((TorqueUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.WindowsRuntimeComponent.g.cs index 1bb83af3e0..7ba67f85c4 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class VitaminA : IQuantity static VitaminA() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.VitaminA, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit InternationalUnit. @@ -98,6 +99,9 @@ private VitaminA(double numericValue, VitaminAUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private VitaminA(double numericValue, VitaminAUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public VitaminAUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -463,6 +472,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((VitaminAUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.WindowsRuntimeComponent.g.cs index 05cfda206c..b3abc2b83e 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class Volume : IQuantity static Volume() { BaseDimensions = new BaseDimensions(3, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Volume, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit CubicMeter. @@ -98,6 +99,9 @@ private Volume(double numericValue, VolumeUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private Volume(double numericValue, VolumeUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public VolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1123,6 +1132,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((VolumeUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.WindowsRuntimeComponent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.WindowsRuntimeComponent.g.cs index e46f4ff131..9219610cb3 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.WindowsRuntimeComponent.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.WindowsRuntimeComponent.g.cs @@ -67,6 +67,7 @@ public sealed partial class VolumeFlow : IQuantity static VolumeFlow() { BaseDimensions = new BaseDimensions(3, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.VolumeFlow, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); } /// /// Creates the quantity with a value of 0 in the base unit CubicMeterPerSecond. @@ -98,6 +99,9 @@ private VolumeFlow(double numericValue, VolumeFlowUnit unit) #region Static Properties + /// + internal static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -142,11 +146,16 @@ private VolumeFlow(double numericValue, VolumeFlowUnit unit) /// public double Value => Convert.ToDouble(_value); + /// + object IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public VolumeFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); + internal QuantityInfo QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1168,6 +1177,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(object unit) => As((VolumeFlowUnit)unit); + /// /// Convert to the unit representation . /// diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs new file mode 100644 index 0000000000..20002b116a --- /dev/null +++ b/UnitsNet/CustomCode/Quantity.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnitsNet.InternalHelpers; + +#if WINDOWS_UWP + using FromValue = System.Double; +#else + using FromValue = UnitsNet.QuantityValue; +#endif + +namespace UnitsNet +{ +#if WINDOWS_UWP + internal +#else + public +#endif + partial class Quantity + { + private static readonly Lazy InfosLazy; + + static Quantity() + { + var quantityTypes = Enum.GetValues(typeof(QuantityType)).Cast().Except(new[] {QuantityType.Undefined}).ToArray(); + Types = quantityTypes; + Names = quantityTypes.Select(qt => qt.ToString()).ToArray(); + +#if !WINDOWS_UWP + // A bunch of reflection to enumerate quantity types, instantiate with the default constructor and return its QuantityInfo property + InfosLazy = new Lazy(() => typeof(Length) + .Wrap() + .Assembly + .GetExportedTypes() + .Where(typeof(IQuantity).IsAssignableFrom) + .Where(t => t.Wrap().IsClass || t.Wrap().IsValueType) // Future-proofing: Considering changing quantities from struct to class + .Select(Activator.CreateInstance) + .Cast() + .Select(q => q.QuantityInfo) + .OrderBy(q => q.Name) + .ToArray()); +#endif + } + + /// + /// All enum values of , such as and . + /// + public static QuantityType[] Types { get; } + + /// + /// All enum value names of , such as "Length" and "Mass". + /// + public static string[] Names { get; } + +#if !WINDOWS_UWP + /// + /// All quantity information objects, such as and . + /// + public static QuantityInfo[] Infos => InfosLazy.Value; +#endif + + /// + /// Dynamically construct a quantity. + /// + /// Numeric value. + /// Unit enum value. + /// An object. + /// Unit value is not a know unit enum type. +#if WINDOWS_UWP + internal static IQuantity From(FromValue value, Enum unit) +#else + public static IQuantity From(FromValue value, Enum unit) +#endif + { + if (TryFrom(value, unit, out IQuantity quantity)) + return quantity; + + throw new ArgumentException( + $"Unit value {unit} of type {unit.GetType()} is not a known unit enum type. Expected types like UnitsNet.Units.LengthUnit. Did you pass in a third-party enum type defined outside UnitsNet library?"); + } + + public static IEnumerable GetQuantitiesWithBaseDimensions(BaseDimensions baseDimensions) + { + return InfosLazy.Value.Where(info => info.BaseDimensions.Equals(baseDimensions)); + } + } +} diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs index d6bedd5c92..d58df984a1 100644 --- a/UnitsNet/CustomCode/QuantityParser.cs +++ b/UnitsNet/CustomCode/QuantityParser.cs @@ -121,6 +121,27 @@ internal bool TryParse([NotNull] string str, return TryParseWithRegex(valueString, unitString, fromDelegate, formatProvider, out result); } + /// + /// Workaround for C# not allowing to pass on 'out' param from type Length to IQuantity, even though the are compatible. + /// + [SuppressMessage("ReSharper", "UseStringInterpolation")] + internal bool TryParse([NotNull] string str, + [CanBeNull] IFormatProvider formatProvider, + [NotNull] QuantityFromDelegate fromDelegate, + out IQuantity result) + where TQuantity : IQuantity + where TUnitType : Enum + { + if (TryParse(str, formatProvider, fromDelegate, out TQuantity parsedQuantity)) + { + result = parsedQuantity; + return true; + } + + result = default; + return false; + } + internal string CreateRegexPatternForUnit( TUnitType unit, IFormatProvider formatProvider, diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index 25c12c7b55..6e2ab49532 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -208,7 +208,7 @@ void MapUnitToDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatProvider formatProvider, bool setAsDefault, [NotNull] params string[] abbreviations) { - if (!unitType.IsEnum()) + if (!unitType.Wrap().IsEnum) throw new ArgumentException("Must be an enum type.", nameof(unitType)); if (abbreviations == null) diff --git a/UnitsNet/CustomCode/UnitParser.cs b/UnitsNet/CustomCode/UnitParser.cs index 808b18b44f..7e1d3e093f 100644 --- a/UnitsNet/CustomCode/UnitParser.cs +++ b/UnitsNet/CustomCode/UnitParser.cs @@ -22,7 +22,6 @@ using System; using System.Linq; using JetBrains.Annotations; -using UnitsNet.InternalHelpers; using UnitsNet.Units; // ReSharper disable once CheckNamespace @@ -82,7 +81,7 @@ TUnitType Parse(string unitAbbreviation, [CanBeNull] IFormatProvider #else public #endif - object Parse([NotNull] string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider = null) + Enum Parse([NotNull] string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider = null) { if (unitAbbreviation == null) throw new ArgumentNullException(nameof(unitAbbreviation)); unitAbbreviation = unitAbbreviation.Trim(); @@ -99,7 +98,7 @@ object Parse([NotNull] string unitAbbreviation, Type unitType, [CanBeNull] IForm switch (unitIntValues.Count) { case 1: - return unitIntValues[0]; + return (Enum) Enum.ToObject(unitType, unitIntValues[0]); case 0: throw new UnitNotFoundException($"Unit not found with abbreviation [{unitAbbreviation}] for unit type [{unitType}]."); default: @@ -162,7 +161,12 @@ bool TryParse(string unitAbbreviation, [CanBeNull] IFormatProvider fo /// The unit enum value as out result. /// True if successful. [PublicAPI] - public bool TryParse(string unitAbbreviation, Type unitType, out object unit) +#if WINDOWS_UWP + internal +#else + public +#endif + bool TryParse(string unitAbbreviation, Type unitType, out Enum unit) { return TryParse(unitAbbreviation, unitType, null, out unit); } @@ -181,7 +185,7 @@ public bool TryParse(string unitAbbreviation, Type unitType, out object unit) #else public #endif - bool TryParse(string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider, out object unit) + bool TryParse(string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider, out Enum unit) { if (unitAbbreviation == null) { @@ -190,7 +194,7 @@ bool TryParse(string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvide } unitAbbreviation = unitAbbreviation.Trim(); - unit = GetDefault(unitType); + unit = default; if(!_unitAbbreviationsCache.TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var abbreviations)) return false; @@ -204,19 +208,8 @@ bool TryParse(string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvide if(unitIntValues.Count != 1) return false; - unit = unitIntValues[0]; + unit = (Enum)Enum.ToObject(unitType, unitIntValues[0]); return true; } - - /// - /// Get default(Type) of - /// - /// . - /// Null for reference types, 0 for numeric types and default constructor for the rest. - /// - private static object GetDefault(Type type) - { - return type.IsValueType() ? Activator.CreateInstance(type): null; - } } } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs index c270945249..016930dca8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Acceleration : IQuantity, IEquatable(QuantityType.Acceleration, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Acceleration(double numericValue, AccelerationUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Acceleration(double numericValue, AccelerationUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -576,12 +588,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Accele return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Acceleration left, Acceleration right) + public static bool operator ==(Acceleration left, Acceleration right) { return left.Equals(right); } - public static bool operator !=(Acceleration left, Acceleration right) + public static bool operator !=(Acceleration left, Acceleration right) { return !(left == right); } @@ -677,6 +689,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((AccelerationUnit)unit); + /// /// Convert to the unit representation . /// @@ -690,6 +704,8 @@ public double As(AccelerationUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((AccelerationUnit) unit); + /// /// Converts this Acceleration to another Acceleration with the unit representation . /// @@ -700,6 +716,10 @@ public Acceleration ToUnit(AccelerationUnit unit) return new Acceleration(convertedValue, unit); } + IQuantity IQuantity.ToUnit(AccelerationUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((AccelerationUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs index 269ec5fc28..fd34f9ca2b 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct AmountOfSubstance : IQuantity, IEqu static AmountOfSubstance() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0); + Info = new QuantityInfo(QuantityType.AmountOfSubstance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public AmountOfSubstance(double numericValue, AmountOfSubstanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public AmountOfSubstance(double numericValue, AmountOfSubstanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AmountOfSubstanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -604,12 +616,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Amount return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) + public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) { return left.Equals(right); } - public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) + public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) { return !(left == right); } @@ -705,6 +717,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((AmountOfSubstanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -718,6 +732,8 @@ public double As(AmountOfSubstanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((AmountOfSubstanceUnit) unit); + /// /// Converts this AmountOfSubstance to another AmountOfSubstance with the unit representation . /// @@ -728,6 +744,10 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit) return new AmountOfSubstance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(AmountOfSubstanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((AmountOfSubstanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs index bdd2811a3c..09106f06ab 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct AmplitudeRatio : IQuantity, IEquatable static AmplitudeRatio() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.AmplitudeRatio, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public AmplitudeRatio(double numericValue, AmplitudeRatioUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public AmplitudeRatio(double numericValue, AmplitudeRatioUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AmplitudeRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -458,12 +470,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Amplit return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) + public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) { return left.Equals(right); } - public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) + public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) { return !(left == right); } @@ -559,6 +571,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((AmplitudeRatioUnit)unit); + /// /// Convert to the unit representation . /// @@ -572,6 +586,8 @@ public double As(AmplitudeRatioUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((AmplitudeRatioUnit) unit); + /// /// Converts this AmplitudeRatio to another AmplitudeRatio with the unit representation . /// @@ -582,6 +598,10 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit) return new AmplitudeRatio(convertedValue, unit); } + IQuantity IQuantity.ToUnit(AmplitudeRatioUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((AmplitudeRatioUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs index a40146322e..c74069868b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Angle : IQuantity, IEquatable, IComparab static Angle() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.Angle, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Angle(double numericValue, AngleUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Angle(double numericValue, AngleUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -590,12 +602,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out AngleU return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Angle left, Angle right) + public static bool operator ==(Angle left, Angle right) { return left.Equals(right); } - public static bool operator !=(Angle left, Angle right) + public static bool operator !=(Angle left, Angle right) { return !(left == right); } @@ -691,6 +703,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((AngleUnit)unit); + /// /// Convert to the unit representation . /// @@ -704,6 +718,8 @@ public double As(AngleUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((AngleUnit) unit); + /// /// Converts this Angle to another Angle with the unit representation . /// @@ -714,6 +730,10 @@ public Angle ToUnit(AngleUnit unit) return new Angle(convertedValue, unit); } + IQuantity IQuantity.ToUnit(AngleUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((AngleUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs index d316073a1e..cc442448d1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ApparentEnergy : IQuantity, IEquatable static ApparentEnergy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ApparentEnergy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ApparentEnergy(double numericValue, ApparentEnergyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ApparentEnergy(double numericValue, ApparentEnergyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ApparentEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Appare return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ApparentEnergy left, ApparentEnergy right) + public static bool operator ==(ApparentEnergy left, ApparentEnergy right) { return left.Equals(right); } - public static bool operator !=(ApparentEnergy left, ApparentEnergy right) + public static bool operator !=(ApparentEnergy left, ApparentEnergy right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ApparentEnergyUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(ApparentEnergyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ApparentEnergyUnit) unit); + /// /// Converts this ApparentEnergy to another ApparentEnergy with the unit representation . /// @@ -560,6 +576,10 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit) return new ApparentEnergy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ApparentEnergyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ApparentEnergyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs index 939303cc36..15141ed781 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ApparentPower : IQuantity, IEquatable(QuantityType.ApparentPower, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ApparentPower(double numericValue, ApparentPowerUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ApparentPower(double numericValue, ApparentPowerUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ApparentPowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -450,12 +462,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Appare return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ApparentPower left, ApparentPower right) + public static bool operator ==(ApparentPower left, ApparentPower right) { return left.Equals(right); } - public static bool operator !=(ApparentPower left, ApparentPower right) + public static bool operator !=(ApparentPower left, ApparentPower right) { return !(left == right); } @@ -551,6 +563,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ApparentPowerUnit)unit); + /// /// Convert to the unit representation . /// @@ -564,6 +578,8 @@ public double As(ApparentPowerUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ApparentPowerUnit) unit); + /// /// Converts this ApparentPower to another ApparentPower with the unit representation . /// @@ -574,6 +590,10 @@ public ApparentPower ToUnit(ApparentPowerUnit unit) return new ApparentPower(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ApparentPowerUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ApparentPowerUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs index cc853e61b1..640710408d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Area : IQuantity, IEquatable, IComparable, static Area() { BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Area, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Area(double numericValue, AreaUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Area(double numericValue, AreaUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AreaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -576,12 +588,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out AreaUn return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Area left, Area right) + public static bool operator ==(Area left, Area right) { return left.Equals(right); } - public static bool operator !=(Area left, Area right) + public static bool operator !=(Area left, Area right) { return !(left == right); } @@ -677,6 +689,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((AreaUnit)unit); + /// /// Convert to the unit representation . /// @@ -690,6 +704,8 @@ public double As(AreaUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((AreaUnit) unit); + /// /// Converts this Area to another Area with the unit representation . /// @@ -700,6 +716,10 @@ public Area ToUnit(AreaUnit unit) return new Area(convertedValue, unit); } + IQuantity IQuantity.ToUnit(AreaUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((AreaUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs index 981c3c9181..30a62aa818 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct AreaDensity : IQuantity, IEquatable(QuantityType.AreaDensity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public AreaDensity(double numericValue, AreaDensityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public AreaDensity(double numericValue, AreaDensityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AreaDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -408,12 +420,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out AreaDe return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(AreaDensity left, AreaDensity right) + public static bool operator ==(AreaDensity left, AreaDensity right) { return left.Equals(right); } - public static bool operator !=(AreaDensity left, AreaDensity right) + public static bool operator !=(AreaDensity left, AreaDensity right) { return !(left == right); } @@ -509,6 +521,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((AreaDensityUnit)unit); + /// /// Convert to the unit representation . /// @@ -522,6 +536,8 @@ public double As(AreaDensityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((AreaDensityUnit) unit); + /// /// Converts this AreaDensity to another AreaDensity with the unit representation . /// @@ -532,6 +548,10 @@ public AreaDensity ToUnit(AreaDensityUnit unit) return new AreaDensity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(AreaDensityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((AreaDensityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs index 94a6104b6f..76416d89a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct AreaMomentOfInertia : IQuantity, static AreaMomentOfInertia() { BaseDimensions = new BaseDimensions(4, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.AreaMomentOfInertia, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public AreaMomentOfInertia(double numericValue, AreaMomentOfInertiaUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public AreaMomentOfInertia(double numericValue, AreaMomentOfInertiaUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public AreaMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -478,12 +490,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out AreaMo return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) { return left.Equals(right); } - public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) { return !(left == right); } @@ -579,6 +591,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((AreaMomentOfInertiaUnit)unit); + /// /// Convert to the unit representation . /// @@ -592,6 +606,8 @@ public double As(AreaMomentOfInertiaUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((AreaMomentOfInertiaUnit) unit); + /// /// Converts this AreaMomentOfInertia to another AreaMomentOfInertia with the unit representation . /// @@ -602,6 +618,10 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit) return new AreaMomentOfInertia(convertedValue, unit); } + IQuantity IQuantity.ToUnit(AreaMomentOfInertiaUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((AreaMomentOfInertiaUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs index 0b5970dc41..1a2d0142ce 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct BitRate : IQuantity, IEquatable, ICo static BitRate() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.BitRate, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public BitRate(decimal numericValue, BitRateUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public BitRate(decimal numericValue, BitRateUnit unit) /// public decimal Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public BitRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -761,12 +773,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out BitRat return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(BitRate left, BitRate right) + public static bool operator ==(BitRate left, BitRate right) { return left.Equals(right); } - public static bool operator !=(BitRate left, BitRate right) + public static bool operator !=(BitRate left, BitRate right) { return !(left == right); } @@ -862,6 +874,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((BitRateUnit)unit); + /// /// Convert to the unit representation . /// @@ -875,6 +889,8 @@ public double As(BitRateUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((BitRateUnit) unit); + /// /// Converts this BitRate to another BitRate with the unit representation . /// @@ -885,6 +901,10 @@ public BitRate ToUnit(BitRateUnit unit) return new BitRate(convertedValue, unit); } + IQuantity IQuantity.ToUnit(BitRateUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((BitRateUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs index a426b07efc..d29de10dae 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct BrakeSpecificFuelConsumption : IQuantity(QuantityType.BrakeSpecificFuelConsumption, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public BrakeSpecificFuelConsumption(double numericValue, BrakeSpecificFuelConsum #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public BrakeSpecificFuelConsumption(double numericValue, BrakeSpecificFuelConsum /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public BrakeSpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out BrakeS return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return left.Equals(right); } - public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((BrakeSpecificFuelConsumptionUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(BrakeSpecificFuelConsumptionUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((BrakeSpecificFuelConsumptionUnit) unit); + /// /// Converts this BrakeSpecificFuelConsumption to another BrakeSpecificFuelConsumption with the unit representation . /// @@ -560,6 +576,10 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit return new BrakeSpecificFuelConsumption(convertedValue, unit); } + IQuantity IQuantity.ToUnit(BrakeSpecificFuelConsumptionUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((BrakeSpecificFuelConsumptionUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs index 781139ac3a..78c09a36de 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Capacitance : IQuantity, IEquatable(QuantityType.Capacitance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Capacitance(double numericValue, CapacitanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Capacitance(double numericValue, CapacitanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public CapacitanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -495,12 +507,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Capaci return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Capacitance left, Capacitance right) + public static bool operator ==(Capacitance left, Capacitance right) { return left.Equals(right); } - public static bool operator !=(Capacitance left, Capacitance right) + public static bool operator !=(Capacitance left, Capacitance right) { return !(left == right); } @@ -596,6 +608,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((CapacitanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -609,6 +623,8 @@ public double As(CapacitanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((CapacitanceUnit) unit); + /// /// Converts this Capacitance to another Capacitance with the unit representation . /// @@ -619,6 +635,10 @@ public Capacitance ToUnit(CapacitanceUnit unit) return new Capacitance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(CapacitanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((CapacitanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs index 9e2c9d0169..d453f51075 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct CoefficientOfThermalExpansion : IQuantity(QuantityType.CoefficientOfThermalExpansion, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public CoefficientOfThermalExpansion(double numericValue, CoefficientOfThermalEx #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public CoefficientOfThermalExpansion(double numericValue, CoefficientOfThermalEx /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public CoefficientOfThermalExpansionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Coeffi return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return left.Equals(right); } - public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((CoefficientOfThermalExpansionUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(CoefficientOfThermalExpansionUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((CoefficientOfThermalExpansionUnit) unit); + /// /// Converts this CoefficientOfThermalExpansion to another CoefficientOfThermalExpansion with the unit representation . /// @@ -560,6 +576,10 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un return new CoefficientOfThermalExpansion(convertedValue, unit); } + IQuantity IQuantity.ToUnit(CoefficientOfThermalExpansionUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((CoefficientOfThermalExpansionUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs index 6bd675f67e..a339a56409 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Density : IQuantity, IEquatable, ICo static Density() { BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Density, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Density(double numericValue, DensityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Density(double numericValue, DensityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public DensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -943,12 +955,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Densit return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Density left, Density right) + public static bool operator ==(Density left, Density right) { return left.Equals(right); } - public static bool operator !=(Density left, Density right) + public static bool operator !=(Density left, Density right) { return !(left == right); } @@ -1044,6 +1056,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((DensityUnit)unit); + /// /// Convert to the unit representation . /// @@ -1057,6 +1071,8 @@ public double As(DensityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((DensityUnit) unit); + /// /// Converts this Density to another Density with the unit representation . /// @@ -1067,6 +1083,10 @@ public Density ToUnit(DensityUnit unit) return new Density(convertedValue, unit); } + IQuantity IQuantity.ToUnit(DensityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((DensityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs index 96839e6452..c036f61726 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Duration : IQuantity, IEquatable, static Duration() { BaseDimensions = new BaseDimensions(0, 0, 1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Duration, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Duration(double numericValue, DurationUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Duration(double numericValue, DurationUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public DurationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -534,12 +546,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Durati return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Duration left, Duration right) + public static bool operator ==(Duration left, Duration right) { return left.Equals(right); } - public static bool operator !=(Duration left, Duration right) + public static bool operator !=(Duration left, Duration right) { return !(left == right); } @@ -635,6 +647,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((DurationUnit)unit); + /// /// Convert to the unit representation . /// @@ -648,6 +662,8 @@ public double As(DurationUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((DurationUnit) unit); + /// /// Converts this Duration to another Duration with the unit representation . /// @@ -658,6 +674,10 @@ public Duration ToUnit(DurationUnit unit) return new Duration(convertedValue, unit); } + IQuantity IQuantity.ToUnit(DurationUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((DurationUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs index d5c144c902..eca7bd5eb5 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct DynamicViscosity : IQuantity, IEquat static DynamicViscosity() { BaseDimensions = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.DynamicViscosity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public DynamicViscosity(double numericValue, DynamicViscosityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public DynamicViscosity(double numericValue, DynamicViscosityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public DynamicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -481,12 +493,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Dynami return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(DynamicViscosity left, DynamicViscosity right) + public static bool operator ==(DynamicViscosity left, DynamicViscosity right) { return left.Equals(right); } - public static bool operator !=(DynamicViscosity left, DynamicViscosity right) + public static bool operator !=(DynamicViscosity left, DynamicViscosity right) { return !(left == right); } @@ -582,6 +594,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((DynamicViscosityUnit)unit); + /// /// Convert to the unit representation . /// @@ -595,6 +609,8 @@ public double As(DynamicViscosityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((DynamicViscosityUnit) unit); + /// /// Converts this DynamicViscosity to another DynamicViscosity with the unit representation . /// @@ -605,6 +621,10 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit) return new DynamicViscosity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(DynamicViscosityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((DynamicViscosityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs index 4fab6a781f..7a616e5826 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ElectricAdmittance : IQuantity, IE static ElectricAdmittance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricAdmittance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ElectricAdmittance(double numericValue, ElectricAdmittanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ElectricAdmittance(double numericValue, ElectricAdmittanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricAdmittanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -450,12 +462,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) + public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) { return left.Equals(right); } - public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) + public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) { return !(left == right); } @@ -551,6 +563,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricAdmittanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -564,6 +578,8 @@ public double As(ElectricAdmittanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricAdmittanceUnit) unit); + /// /// Converts this ElectricAdmittance to another ElectricAdmittance with the unit representation . /// @@ -574,6 +590,10 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit) return new ElectricAdmittance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricAdmittanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricAdmittanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs index fb1cf38f61..cb4b59f11f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricCharge : IQuantity, IEquatable static ElectricCharge() { BaseDimensions = new BaseDimensions(0, 0, 1, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricCharge, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricCharge(double numericValue, ElectricChargeUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricCharge(double numericValue, ElectricChargeUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricChargeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricCharge left, ElectricCharge right) + public static bool operator ==(ElectricCharge left, ElectricCharge right) { return left.Equals(right); } - public static bool operator !=(ElectricCharge left, ElectricCharge right) + public static bool operator !=(ElectricCharge left, ElectricCharge right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricChargeUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(ElectricChargeUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricChargeUnit) unit); + /// /// Converts this ElectricCharge to another ElectricCharge with the unit representation . /// @@ -535,6 +551,10 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit) return new ElectricCharge(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricChargeUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricChargeUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs index 461b8d9b04..8d504424f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricChargeDensity : IQuantity(QuantityType.ElectricChargeDensity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricChargeDensity(double numericValue, ElectricChargeDensityUnit unit #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricChargeDensity(double numericValue, ElectricChargeDensityUnit unit /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricChargeDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) + public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) { return left.Equals(right); } - public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) + public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricChargeDensityUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(ElectricChargeDensityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricChargeDensityUnit) unit); + /// /// Converts this ElectricChargeDensity to another ElectricChargeDensity with the unit representation . /// @@ -535,6 +551,10 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit) return new ElectricChargeDensity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricChargeDensityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricChargeDensityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs index e1fe29fffd..5385a89882 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricConductance : IQuantity, static ElectricConductance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricConductance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricConductance(double numericValue, ElectricConductanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricConductance(double numericValue, ElectricConductanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricConductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -439,12 +451,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricConductance left, ElectricConductance right) + public static bool operator ==(ElectricConductance left, ElectricConductance right) { return left.Equals(right); } - public static bool operator !=(ElectricConductance left, ElectricConductance right) + public static bool operator !=(ElectricConductance left, ElectricConductance right) { return !(left == right); } @@ -540,6 +552,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricConductanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -553,6 +567,8 @@ public double As(ElectricConductanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricConductanceUnit) unit); + /// /// Converts this ElectricConductance to another ElectricConductance with the unit representation . /// @@ -563,6 +579,10 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit) return new ElectricConductance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricConductanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricConductanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs index be0f11ec85..3c78090e09 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricConductivity : IQuantity static ElectricConductivity() { BaseDimensions = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricConductivity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricConductivity(double numericValue, ElectricConductivityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricConductivity(double numericValue, ElectricConductivityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricConductivity left, ElectricConductivity right) + public static bool operator ==(ElectricConductivity left, ElectricConductivity right) { return left.Equals(right); } - public static bool operator !=(ElectricConductivity left, ElectricConductivity right) + public static bool operator !=(ElectricConductivity left, ElectricConductivity right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricConductivityUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(ElectricConductivityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricConductivityUnit) unit); + /// /// Converts this ElectricConductivity to another ElectricConductivity with the unit representation . /// @@ -535,6 +551,10 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit) return new ElectricConductivity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricConductivityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricConductivityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs index 363b81c633..3cee65c54b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ElectricCurrent : IQuantity, IEquatab static ElectricCurrent() { BaseDimensions = new BaseDimensions(0, 0, 0, 1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricCurrent, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ElectricCurrent(double numericValue, ElectricCurrentUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ElectricCurrent(double numericValue, ElectricCurrentUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricCurrentUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -506,12 +518,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricCurrent left, ElectricCurrent right) + public static bool operator ==(ElectricCurrent left, ElectricCurrent right) { return left.Equals(right); } - public static bool operator !=(ElectricCurrent left, ElectricCurrent right) + public static bool operator !=(ElectricCurrent left, ElectricCurrent right) { return !(left == right); } @@ -607,6 +619,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricCurrentUnit)unit); + /// /// Convert to the unit representation . /// @@ -620,6 +634,8 @@ public double As(ElectricCurrentUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricCurrentUnit) unit); + /// /// Converts this ElectricCurrent to another ElectricCurrent with the unit representation . /// @@ -630,6 +646,10 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit) return new ElectricCurrent(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricCurrentUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricCurrentUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs index b7001e7b26..95b7c8b29a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricCurrentDensity : IQuantity(QuantityType.ElectricCurrentDensity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricCurrentDensity(double numericValue, ElectricCurrentDensityUnit un #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricCurrentDensity(double numericValue, ElectricCurrentDensityUnit un /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricCurrentDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) { return left.Equals(right); } - public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricCurrentDensityUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(ElectricCurrentDensityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricCurrentDensityUnit) unit); + /// /// Converts this ElectricCurrentDensity to another ElectricCurrentDensity with the unit representation . /// @@ -535,6 +551,10 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit) return new ElectricCurrentDensity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricCurrentDensityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricCurrentDensityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs index 4bb134d584..5029fbc097 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ElectricCurrentGradient : IQuantity(QuantityType.ElectricCurrentGradient, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ElectricCurrentGradient(double numericValue, ElectricCurrentGradientUnit #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ElectricCurrentGradient(double numericValue, ElectricCurrentGradientUnit /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricCurrentGradientUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -408,12 +420,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) { return left.Equals(right); } - public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) { return !(left == right); } @@ -509,6 +521,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricCurrentGradientUnit)unit); + /// /// Convert to the unit representation . /// @@ -522,6 +536,8 @@ public double As(ElectricCurrentGradientUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricCurrentGradientUnit) unit); + /// /// Converts this ElectricCurrentGradient to another ElectricCurrentGradient with the unit representation . /// @@ -532,6 +548,10 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit) return new ElectricCurrentGradient(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricCurrentGradientUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricCurrentGradientUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs index 4b6fdb2dbf..f840bd059c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricField : IQuantity, IEquatable(QuantityType.ElectricField, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricField(double numericValue, ElectricFieldUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricField(double numericValue, ElectricFieldUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricField left, ElectricField right) + public static bool operator ==(ElectricField left, ElectricField right) { return left.Equals(right); } - public static bool operator !=(ElectricField left, ElectricField right) + public static bool operator !=(ElectricField left, ElectricField right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricFieldUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(ElectricFieldUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricFieldUnit) unit); + /// /// Converts this ElectricField to another ElectricField with the unit representation . /// @@ -535,6 +551,10 @@ public ElectricField ToUnit(ElectricFieldUnit unit) return new ElectricField(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricFieldUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricFieldUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs index 80df2fca68..3a0c65aaee 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricInductance : IQuantity, IE static ElectricInductance() { BaseDimensions = new BaseDimensions(2, 1, -2, -2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricInductance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricInductance(double numericValue, ElectricInductanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricInductance(double numericValue, ElectricInductanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricInductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -453,12 +465,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricInductance left, ElectricInductance right) + public static bool operator ==(ElectricInductance left, ElectricInductance right) { return left.Equals(right); } - public static bool operator !=(ElectricInductance left, ElectricInductance right) + public static bool operator !=(ElectricInductance left, ElectricInductance right) { return !(left == right); } @@ -554,6 +566,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricInductanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -567,6 +581,8 @@ public double As(ElectricInductanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricInductanceUnit) unit); + /// /// Converts this ElectricInductance to another ElectricInductance with the unit representation . /// @@ -577,6 +593,10 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit) return new ElectricInductance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricInductanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricInductanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs index cd2d3b1af4..dce322ff62 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ElectricPotential : IQuantity, IEqu static ElectricPotential() { BaseDimensions = new BaseDimensions(2, 1, -3, -1, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricPotential, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ElectricPotential(double numericValue, ElectricPotentialUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ElectricPotential(double numericValue, ElectricPotentialUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricPotentialUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -464,12 +476,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricPotential left, ElectricPotential right) + public static bool operator ==(ElectricPotential left, ElectricPotential right) { return left.Equals(right); } - public static bool operator !=(ElectricPotential left, ElectricPotential right) + public static bool operator !=(ElectricPotential left, ElectricPotential right) { return !(left == right); } @@ -565,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricPotentialUnit)unit); + /// /// Convert to the unit representation . /// @@ -578,6 +592,8 @@ public double As(ElectricPotentialUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricPotentialUnit) unit); + /// /// Converts this ElectricPotential to another ElectricPotential with the unit representation . /// @@ -588,6 +604,10 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit) return new ElectricPotential(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricPotentialUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricPotentialUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs index fd40d4efdd..44ea05d6d8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ElectricPotentialAc : IQuantity, static ElectricPotentialAc() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.ElectricPotentialAc, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ElectricPotentialAc(double numericValue, ElectricPotentialAcUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ElectricPotentialAc(double numericValue, ElectricPotentialAcUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricPotentialAcUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -464,12 +476,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) + public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) { return left.Equals(right); } - public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) + public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) { return !(left == right); } @@ -565,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricPotentialAcUnit)unit); + /// /// Convert to the unit representation . /// @@ -578,6 +592,8 @@ public double As(ElectricPotentialAcUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricPotentialAcUnit) unit); + /// /// Converts this ElectricPotentialAc to another ElectricPotentialAc with the unit representation . /// @@ -588,6 +604,10 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit) return new ElectricPotentialAc(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricPotentialAcUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricPotentialAcUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs index fd30ab0765..546927f34f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ElectricPotentialDc : IQuantity, static ElectricPotentialDc() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.ElectricPotentialDc, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ElectricPotentialDc(double numericValue, ElectricPotentialDcUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ElectricPotentialDc(double numericValue, ElectricPotentialDcUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricPotentialDcUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -464,12 +476,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) + public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) { return left.Equals(right); } - public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) + public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) { return !(left == right); } @@ -565,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricPotentialDcUnit)unit); + /// /// Convert to the unit representation . /// @@ -578,6 +592,8 @@ public double As(ElectricPotentialDcUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricPotentialDcUnit) unit); + /// /// Converts this ElectricPotentialDc to another ElectricPotentialDc with the unit representation . /// @@ -588,6 +604,10 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit) return new ElectricPotentialDc(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricPotentialDcUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricPotentialDcUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs index d2ea46101d..1ade45134d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ElectricResistance : IQuantity, IE static ElectricResistance() { BaseDimensions = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricResistance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ElectricResistance(double numericValue, ElectricResistanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ElectricResistance(double numericValue, ElectricResistanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -464,12 +476,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricResistance left, ElectricResistance right) + public static bool operator ==(ElectricResistance left, ElectricResistance right) { return left.Equals(right); } - public static bool operator !=(ElectricResistance left, ElectricResistance right) + public static bool operator !=(ElectricResistance left, ElectricResistance right) { return !(left == right); } @@ -565,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricResistanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -578,6 +592,8 @@ public double As(ElectricResistanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricResistanceUnit) unit); + /// /// Converts this ElectricResistance to another ElectricResistance with the unit representation . /// @@ -588,6 +604,10 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit) return new ElectricResistance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricResistanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricResistanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs index e4771a7041..83af49e1f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ElectricResistivity : IQuantity, static ElectricResistivity() { BaseDimensions = new BaseDimensions(3, 1, -3, -2, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ElectricResistivity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ElectricResistivity(double numericValue, ElectricResistivityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ElectricResistivity(double numericValue, ElectricResistivityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ElectricResistivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -593,12 +605,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Electr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ElectricResistivity left, ElectricResistivity right) + public static bool operator ==(ElectricResistivity left, ElectricResistivity right) { return left.Equals(right); } - public static bool operator !=(ElectricResistivity left, ElectricResistivity right) + public static bool operator !=(ElectricResistivity left, ElectricResistivity right) { return !(left == right); } @@ -694,6 +706,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ElectricResistivityUnit)unit); + /// /// Convert to the unit representation . /// @@ -707,6 +721,8 @@ public double As(ElectricResistivityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ElectricResistivityUnit) unit); + /// /// Converts this ElectricResistivity to another ElectricResistivity with the unit representation . /// @@ -717,6 +733,10 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit) return new ElectricResistivity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ElectricResistivityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ElectricResistivityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs index b6b7eb3cc2..00b228efba 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Energy : IQuantity, IEquatable, ICompa static Energy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Energy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Energy(double numericValue, EnergyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Energy(double numericValue, EnergyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public EnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -702,12 +714,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Energy return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Energy left, Energy right) + public static bool operator ==(Energy left, Energy right) { return left.Equals(right); } - public static bool operator !=(Energy left, Energy right) + public static bool operator !=(Energy left, Energy right) { return !(left == right); } @@ -803,6 +815,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((EnergyUnit)unit); + /// /// Convert to the unit representation . /// @@ -816,6 +830,8 @@ public double As(EnergyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((EnergyUnit) unit); + /// /// Converts this Energy to another Energy with the unit representation . /// @@ -826,6 +842,10 @@ public Energy ToUnit(EnergyUnit unit) return new Energy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(EnergyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((EnergyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs index 4662db9594..d935706da4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Entropy : IQuantity, IEquatable, ICo static Entropy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.Entropy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Entropy(double numericValue, EntropyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Entropy(double numericValue, EntropyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public EntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -492,12 +504,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Entrop return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Entropy left, Entropy right) + public static bool operator ==(Entropy left, Entropy right) { return left.Equals(right); } - public static bool operator !=(Entropy left, Entropy right) + public static bool operator !=(Entropy left, Entropy right) { return !(left == right); } @@ -593,6 +605,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((EntropyUnit)unit); + /// /// Convert to the unit representation . /// @@ -606,6 +620,8 @@ public double As(EntropyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((EntropyUnit) unit); + /// /// Converts this Entropy to another Entropy with the unit representation . /// @@ -616,6 +632,10 @@ public Entropy ToUnit(EntropyUnit unit) return new Entropy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(EntropyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((EntropyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs index 6ebd52954a..3db6a29d7b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Force : IQuantity, IEquatable, IComparab static Force() { BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Force, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Force(double numericValue, ForceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Force(double numericValue, ForceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ForceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -576,12 +588,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out ForceU return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Force left, Force right) + public static bool operator ==(Force left, Force right) { return left.Equals(right); } - public static bool operator !=(Force left, Force right) + public static bool operator !=(Force left, Force right) { return !(left == right); } @@ -677,6 +689,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ForceUnit)unit); + /// /// Convert to the unit representation . /// @@ -690,6 +704,8 @@ public double As(ForceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ForceUnit) unit); + /// /// Converts this Force to another Force with the unit representation . /// @@ -700,6 +716,10 @@ public Force ToUnit(ForceUnit unit) return new Force(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ForceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ForceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs index af21f65c43..06bf7726d1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ForceChangeRate : IQuantity, IEquatab static ForceChangeRate() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ForceChangeRate, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ForceChangeRate(double numericValue, ForceChangeRateUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ForceChangeRate(double numericValue, ForceChangeRateUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ForceChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -548,12 +560,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out ForceC return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ForceChangeRate left, ForceChangeRate right) + public static bool operator ==(ForceChangeRate left, ForceChangeRate right) { return left.Equals(right); } - public static bool operator !=(ForceChangeRate left, ForceChangeRate right) + public static bool operator !=(ForceChangeRate left, ForceChangeRate right) { return !(left == right); } @@ -649,6 +661,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ForceChangeRateUnit)unit); + /// /// Convert to the unit representation . /// @@ -662,6 +676,8 @@ public double As(ForceChangeRateUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ForceChangeRateUnit) unit); + /// /// Converts this ForceChangeRate to another ForceChangeRate with the unit representation . /// @@ -672,6 +688,10 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit) return new ForceChangeRate(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ForceChangeRateUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ForceChangeRateUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs index 8f60b98ec5..97d6c4d6d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ForcePerLength : IQuantity, IEquatable static ForcePerLength() { BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ForcePerLength, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ForcePerLength(double numericValue, ForcePerLengthUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ForcePerLength(double numericValue, ForcePerLengthUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ForcePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -520,12 +532,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out ForceP return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ForcePerLength left, ForcePerLength right) + public static bool operator ==(ForcePerLength left, ForcePerLength right) { return left.Equals(right); } - public static bool operator !=(ForcePerLength left, ForcePerLength right) + public static bool operator !=(ForcePerLength left, ForcePerLength right) { return !(left == right); } @@ -621,6 +633,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ForcePerLengthUnit)unit); + /// /// Convert to the unit representation . /// @@ -634,6 +648,8 @@ public double As(ForcePerLengthUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ForcePerLengthUnit) unit); + /// /// Converts this ForcePerLength to another ForcePerLength with the unit representation . /// @@ -644,6 +660,10 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit) return new ForcePerLength(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ForcePerLengthUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ForcePerLengthUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs index 10885386a6..705c777249 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Frequency : IQuantity, IEquatable(QuantityType.Frequency, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Frequency(double numericValue, FrequencyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Frequency(double numericValue, FrequencyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public FrequencyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -506,12 +518,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Freque return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Frequency left, Frequency right) + public static bool operator ==(Frequency left, Frequency right) { return left.Equals(right); } - public static bool operator !=(Frequency left, Frequency right) + public static bool operator !=(Frequency left, Frequency right) { return !(left == right); } @@ -607,6 +619,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((FrequencyUnit)unit); + /// /// Convert to the unit representation . /// @@ -620,6 +634,8 @@ public double As(FrequencyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((FrequencyUnit) unit); + /// /// Converts this Frequency to another Frequency with the unit representation . /// @@ -630,6 +646,10 @@ public Frequency ToUnit(FrequencyUnit unit) return new Frequency(convertedValue, unit); } + IQuantity IQuantity.ToUnit(FrequencyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((FrequencyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs index efa64bfcd3..08115fe8d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct HeatFlux : IQuantity, IEquatable, static HeatFlux() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.HeatFlux, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public HeatFlux(double numericValue, HeatFluxUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public HeatFlux(double numericValue, HeatFluxUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public HeatFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -646,12 +658,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out HeatFl return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(HeatFlux left, HeatFlux right) + public static bool operator ==(HeatFlux left, HeatFlux right) { return left.Equals(right); } - public static bool operator !=(HeatFlux left, HeatFlux right) + public static bool operator !=(HeatFlux left, HeatFlux right) { return !(left == right); } @@ -747,6 +759,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((HeatFluxUnit)unit); + /// /// Convert to the unit representation . /// @@ -760,6 +774,8 @@ public double As(HeatFluxUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((HeatFluxUnit) unit); + /// /// Converts this HeatFlux to another HeatFlux with the unit representation . /// @@ -770,6 +786,10 @@ public HeatFlux ToUnit(HeatFluxUnit unit) return new HeatFlux(convertedValue, unit); } + IQuantity IQuantity.ToUnit(HeatFluxUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((HeatFluxUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs index 06ca66abcf..d115d362b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct HeatTransferCoefficient : IQuantity(QuantityType.HeatTransferCoefficient, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public HeatTransferCoefficient(double numericValue, HeatTransferCoefficientUnit #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public HeatTransferCoefficient(double numericValue, HeatTransferCoefficientUnit /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public HeatTransferCoefficientUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -422,12 +434,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out HeatTr return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) { return left.Equals(right); } - public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) { return !(left == right); } @@ -523,6 +535,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((HeatTransferCoefficientUnit)unit); + /// /// Convert to the unit representation . /// @@ -536,6 +550,8 @@ public double As(HeatTransferCoefficientUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((HeatTransferCoefficientUnit) unit); + /// /// Converts this HeatTransferCoefficient to another HeatTransferCoefficient with the unit representation . /// @@ -546,6 +562,10 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit) return new HeatTransferCoefficient(convertedValue, unit); } + IQuantity IQuantity.ToUnit(HeatTransferCoefficientUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((HeatTransferCoefficientUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs index deb0dfd964..7a5b022742 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Illuminance : IQuantity, IEquatable(QuantityType.Illuminance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Illuminance(double numericValue, IlluminanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Illuminance(double numericValue, IlluminanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public IlluminanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -453,12 +465,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Illumi return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Illuminance left, Illuminance right) + public static bool operator ==(Illuminance left, Illuminance right) { return left.Equals(right); } - public static bool operator !=(Illuminance left, Illuminance right) + public static bool operator !=(Illuminance left, Illuminance right) { return !(left == right); } @@ -554,6 +566,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((IlluminanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -567,6 +581,8 @@ public double As(IlluminanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((IlluminanceUnit) unit); + /// /// Converts this Illuminance to another Illuminance with the unit representation . /// @@ -577,6 +593,10 @@ public Illuminance ToUnit(IlluminanceUnit unit) return new Illuminance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(IlluminanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((IlluminanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs index 33ae00e2bc..93c6052602 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Information : IQuantity, IEquatable(QuantityType.Information, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Information(decimal numericValue, InformationUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Information(decimal numericValue, InformationUnit unit) /// public decimal Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public InformationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -758,12 +770,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Inform return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Information left, Information right) + public static bool operator ==(Information left, Information right) { return left.Equals(right); } - public static bool operator !=(Information left, Information right) + public static bool operator !=(Information left, Information right) { return !(left == right); } @@ -859,6 +871,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((InformationUnit)unit); + /// /// Convert to the unit representation . /// @@ -872,6 +886,8 @@ public double As(InformationUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((InformationUnit) unit); + /// /// Converts this Information to another Information with the unit representation . /// @@ -882,6 +898,10 @@ public Information ToUnit(InformationUnit unit) return new Information(convertedValue, unit); } + IQuantity IQuantity.ToUnit(InformationUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((InformationUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs index ac2f12ef3d..c3ab0cef4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Irradiance : IQuantity, IEquatable(QuantityType.Irradiance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Irradiance(double numericValue, IrradianceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Irradiance(double numericValue, IrradianceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public IrradianceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -590,12 +602,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Irradi return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Irradiance left, Irradiance right) + public static bool operator ==(Irradiance left, Irradiance right) { return left.Equals(right); } - public static bool operator !=(Irradiance left, Irradiance right) + public static bool operator !=(Irradiance left, Irradiance right) { return !(left == right); } @@ -691,6 +703,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((IrradianceUnit)unit); + /// /// Convert to the unit representation . /// @@ -704,6 +718,8 @@ public double As(IrradianceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((IrradianceUnit) unit); + /// /// Converts this Irradiance to another Irradiance with the unit representation . /// @@ -714,6 +730,10 @@ public Irradiance ToUnit(IrradianceUnit unit) return new Irradiance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(IrradianceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((IrradianceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs index dca928f3c6..58f5bcd9b9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Irradiation : IQuantity, IEquatable(QuantityType.Irradiation, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Irradiation(double numericValue, IrradiationUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Irradiation(double numericValue, IrradiationUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public IrradiationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -453,12 +465,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Irradi return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Irradiation left, Irradiation right) + public static bool operator ==(Irradiation left, Irradiation right) { return left.Equals(right); } - public static bool operator !=(Irradiation left, Irradiation right) + public static bool operator !=(Irradiation left, Irradiation right) { return !(left == right); } @@ -554,6 +566,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((IrradiationUnit)unit); + /// /// Convert to the unit representation . /// @@ -567,6 +581,8 @@ public double As(IrradiationUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((IrradiationUnit) unit); + /// /// Converts this Irradiation to another Irradiation with the unit representation . /// @@ -577,6 +593,10 @@ public Irradiation ToUnit(IrradiationUnit unit) return new Irradiation(convertedValue, unit); } + IQuantity IQuantity.ToUnit(IrradiationUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((IrradiationUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs index 2706ee8908..68ee3b490a 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct KinematicViscosity : IQuantity, IE static KinematicViscosity() { BaseDimensions = new BaseDimensions(2, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.KinematicViscosity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public KinematicViscosity(double numericValue, KinematicViscosityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public KinematicViscosity(double numericValue, KinematicViscosityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public KinematicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -509,12 +521,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Kinema return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(KinematicViscosity left, KinematicViscosity right) + public static bool operator ==(KinematicViscosity left, KinematicViscosity right) { return left.Equals(right); } - public static bool operator !=(KinematicViscosity left, KinematicViscosity right) + public static bool operator !=(KinematicViscosity left, KinematicViscosity right) { return !(left == right); } @@ -610,6 +622,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((KinematicViscosityUnit)unit); + /// /// Convert to the unit representation . /// @@ -623,6 +637,8 @@ public double As(KinematicViscosityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((KinematicViscosityUnit) unit); + /// /// Converts this KinematicViscosity to another KinematicViscosity with the unit representation . /// @@ -633,6 +649,10 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit) return new KinematicViscosity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(KinematicViscosityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((KinematicViscosityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs index 32917196b5..29e86cd2fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct LapseRate : IQuantity, IEquatable(QuantityType.LapseRate, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public LapseRate(double numericValue, LapseRateUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public LapseRate(double numericValue, LapseRateUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LapseRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -408,12 +420,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out LapseR return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(LapseRate left, LapseRate right) + public static bool operator ==(LapseRate left, LapseRate right) { return left.Equals(right); } - public static bool operator !=(LapseRate left, LapseRate right) + public static bool operator !=(LapseRate left, LapseRate right) { return !(left == right); } @@ -509,6 +521,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((LapseRateUnit)unit); + /// /// Convert to the unit representation . /// @@ -522,6 +536,8 @@ public double As(LapseRateUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((LapseRateUnit) unit); + /// /// Converts this LapseRate to another LapseRate with the unit representation . /// @@ -532,6 +548,10 @@ public LapseRate ToUnit(LapseRateUnit unit) return new LapseRate(convertedValue, unit); } + IQuantity IQuantity.ToUnit(LapseRateUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((LapseRateUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs index b99f958318..01b5503c8e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Length : IQuantity, IEquatable, ICompa static Length() { BaseDimensions = new BaseDimensions(1, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Length, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Length(double numericValue, LengthUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Length(double numericValue, LengthUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -702,12 +714,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Length return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Length left, Length right) + public static bool operator ==(Length left, Length right) { return left.Equals(right); } - public static bool operator !=(Length left, Length right) + public static bool operator !=(Length left, Length right) { return !(left == right); } @@ -803,6 +815,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((LengthUnit)unit); + /// /// Convert to the unit representation . /// @@ -816,6 +830,8 @@ public double As(LengthUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((LengthUnit) unit); + /// /// Converts this Length to another Length with the unit representation . /// @@ -826,6 +842,10 @@ public Length ToUnit(LengthUnit unit) return new Length(convertedValue, unit); } + IQuantity IQuantity.ToUnit(LengthUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((LengthUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs index 2341a73eb2..6df7a092ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Level : IQuantity, IEquatable, IComparab static Level() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.Level, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Level(double numericValue, LevelUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Level(double numericValue, LevelUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LevelUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -430,12 +442,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out LevelU return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Level left, Level right) + public static bool operator ==(Level left, Level right) { return left.Equals(right); } - public static bool operator !=(Level left, Level right) + public static bool operator !=(Level left, Level right) { return !(left == right); } @@ -531,6 +543,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((LevelUnit)unit); + /// /// Convert to the unit representation . /// @@ -544,6 +558,8 @@ public double As(LevelUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((LevelUnit) unit); + /// /// Converts this Level to another Level with the unit representation . /// @@ -554,6 +570,10 @@ public Level ToUnit(LevelUnit unit) return new Level(convertedValue, unit); } + IQuantity IQuantity.ToUnit(LevelUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((LevelUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs index 2181591ddb..5c5a8db201 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct LinearDensity : IQuantity, IEquatable(QuantityType.LinearDensity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public LinearDensity(double numericValue, LinearDensityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public LinearDensity(double numericValue, LinearDensityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LinearDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -439,12 +451,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Linear return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(LinearDensity left, LinearDensity right) + public static bool operator ==(LinearDensity left, LinearDensity right) { return left.Equals(right); } - public static bool operator !=(LinearDensity left, LinearDensity right) + public static bool operator !=(LinearDensity left, LinearDensity right) { return !(left == right); } @@ -540,6 +552,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((LinearDensityUnit)unit); + /// /// Convert to the unit representation . /// @@ -553,6 +567,8 @@ public double As(LinearDensityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((LinearDensityUnit) unit); + /// /// Converts this LinearDensity to another LinearDensity with the unit representation . /// @@ -563,6 +579,10 @@ public LinearDensity ToUnit(LinearDensityUnit unit) return new LinearDensity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(LinearDensityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((LinearDensityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs index b607dcf7d5..84ab41b25f 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct LuminousFlux : IQuantity, IEquatable(QuantityType.LuminousFlux, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public LuminousFlux(double numericValue, LuminousFluxUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public LuminousFlux(double numericValue, LuminousFluxUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LuminousFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Lumino return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(LuminousFlux left, LuminousFlux right) + public static bool operator ==(LuminousFlux left, LuminousFlux right) { return left.Equals(right); } - public static bool operator !=(LuminousFlux left, LuminousFlux right) + public static bool operator !=(LuminousFlux left, LuminousFlux right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((LuminousFluxUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(LuminousFluxUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((LuminousFluxUnit) unit); + /// /// Converts this LuminousFlux to another LuminousFlux with the unit representation . /// @@ -535,6 +551,10 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit) return new LuminousFlux(convertedValue, unit); } + IQuantity IQuantity.ToUnit(LuminousFluxUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((LuminousFluxUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs index 140d69e819..0ec506ed85 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct LuminousIntensity : IQuantity, IEqu static LuminousIntensity() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); + Info = new QuantityInfo(QuantityType.LuminousIntensity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public LuminousIntensity(double numericValue, LuminousIntensityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public LuminousIntensity(double numericValue, LuminousIntensityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public LuminousIntensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Lumino return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(LuminousIntensity left, LuminousIntensity right) + public static bool operator ==(LuminousIntensity left, LuminousIntensity right) { return left.Equals(right); } - public static bool operator !=(LuminousIntensity left, LuminousIntensity right) + public static bool operator !=(LuminousIntensity left, LuminousIntensity right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((LuminousIntensityUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(LuminousIntensityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((LuminousIntensityUnit) unit); + /// /// Converts this LuminousIntensity to another LuminousIntensity with the unit representation . /// @@ -535,6 +551,10 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit) return new LuminousIntensity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(LuminousIntensityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((LuminousIntensityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs index d41a947096..e00b561fa1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct MagneticField : IQuantity, IEquatable(QuantityType.MagneticField, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public MagneticField(double numericValue, MagneticFieldUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public MagneticField(double numericValue, MagneticFieldUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MagneticFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -453,12 +465,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Magnet return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MagneticField left, MagneticField right) + public static bool operator ==(MagneticField left, MagneticField right) { return left.Equals(right); } - public static bool operator !=(MagneticField left, MagneticField right) + public static bool operator !=(MagneticField left, MagneticField right) { return !(left == right); } @@ -554,6 +566,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MagneticFieldUnit)unit); + /// /// Convert to the unit representation . /// @@ -567,6 +581,8 @@ public double As(MagneticFieldUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MagneticFieldUnit) unit); + /// /// Converts this MagneticField to another MagneticField with the unit representation . /// @@ -577,6 +593,10 @@ public MagneticField ToUnit(MagneticFieldUnit unit) return new MagneticField(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MagneticFieldUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MagneticFieldUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs index dbdd27fde0..57f4768d5c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct MagneticFlux : IQuantity, IEquatable(QuantityType.MagneticFlux, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public MagneticFlux(double numericValue, MagneticFluxUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public MagneticFlux(double numericValue, MagneticFluxUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MagneticFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Magnet return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MagneticFlux left, MagneticFlux right) + public static bool operator ==(MagneticFlux left, MagneticFlux right) { return left.Equals(right); } - public static bool operator !=(MagneticFlux left, MagneticFlux right) + public static bool operator !=(MagneticFlux left, MagneticFlux right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MagneticFluxUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(MagneticFluxUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MagneticFluxUnit) unit); + /// /// Converts this MagneticFlux to another MagneticFlux with the unit representation . /// @@ -535,6 +551,10 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit) return new MagneticFlux(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MagneticFluxUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MagneticFluxUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs index 176584354c..9a50cb6aca 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Magnetization : IQuantity, IEquatable(QuantityType.Magnetization, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Magnetization(double numericValue, MagnetizationUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Magnetization(double numericValue, MagnetizationUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MagnetizationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Magnet return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Magnetization left, Magnetization right) + public static bool operator ==(Magnetization left, Magnetization right) { return left.Equals(right); } - public static bool operator !=(Magnetization left, Magnetization right) + public static bool operator !=(Magnetization left, Magnetization right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MagnetizationUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(MagnetizationUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MagnetizationUnit) unit); + /// /// Converts this Magnetization to another Magnetization with the unit representation . /// @@ -535,6 +551,10 @@ public Magnetization ToUnit(MagnetizationUnit unit) return new Magnetization(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MagnetizationUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MagnetizationUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs index db50819870..3e8fced32c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Mass : IQuantity, IEquatable, IComparable, static Mass() { BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Mass, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Mass(double numericValue, MassUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Mass(double numericValue, MassUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -716,12 +728,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out MassUn return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Mass left, Mass right) + public static bool operator ==(Mass left, Mass right) { return left.Equals(right); } - public static bool operator !=(Mass left, Mass right) + public static bool operator !=(Mass left, Mass right) { return !(left == right); } @@ -817,6 +829,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MassUnit)unit); + /// /// Convert to the unit representation . /// @@ -830,6 +844,8 @@ public double As(MassUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MassUnit) unit); + /// /// Converts this Mass to another Mass with the unit representation . /// @@ -840,6 +856,10 @@ public Mass ToUnit(MassUnit unit) return new Mass(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MassUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MassUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs index 506ff0ba9d..cca40ad62a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct MassFlow : IQuantity, IEquatable, static MassFlow() { BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MassFlow, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public MassFlow(double numericValue, MassFlowUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public MassFlow(double numericValue, MassFlowUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -828,12 +840,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out MassFl return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MassFlow left, MassFlow right) + public static bool operator ==(MassFlow left, MassFlow right) { return left.Equals(right); } - public static bool operator !=(MassFlow left, MassFlow right) + public static bool operator !=(MassFlow left, MassFlow right) { return !(left == right); } @@ -929,6 +941,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MassFlowUnit)unit); + /// /// Convert to the unit representation . /// @@ -942,6 +956,8 @@ public double As(MassFlowUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MassFlowUnit) unit); + /// /// Converts this MassFlow to another MassFlow with the unit representation . /// @@ -952,6 +968,10 @@ public MassFlow ToUnit(MassFlowUnit unit) return new MassFlow(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MassFlowUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MassFlowUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs index 0c811035cf..48dc3b3355 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct MassFlux : IQuantity, IEquatable, static MassFlux() { BaseDimensions = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MassFlux, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public MassFlux(double numericValue, MassFluxUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public MassFlux(double numericValue, MassFluxUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -422,12 +434,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out MassFl return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MassFlux left, MassFlux right) + public static bool operator ==(MassFlux left, MassFlux right) { return left.Equals(right); } - public static bool operator !=(MassFlux left, MassFlux right) + public static bool operator !=(MassFlux left, MassFlux right) { return !(left == right); } @@ -523,6 +535,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MassFluxUnit)unit); + /// /// Convert to the unit representation . /// @@ -536,6 +550,8 @@ public double As(MassFluxUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MassFluxUnit) unit); + /// /// Converts this MassFlux to another MassFlux with the unit representation . /// @@ -546,6 +562,10 @@ public MassFlux ToUnit(MassFluxUnit unit) return new MassFlux(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MassFluxUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MassFluxUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs index 82b43eb65f..775f054e6d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct MassMomentOfInertia : IQuantity, static MassMomentOfInertia() { BaseDimensions = new BaseDimensions(2, 1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.MassMomentOfInertia, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public MassMomentOfInertia(double numericValue, MassMomentOfInertiaUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public MassMomentOfInertia(double numericValue, MassMomentOfInertiaUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MassMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -786,12 +798,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out MassMo return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) + public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) { return left.Equals(right); } - public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) + public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) { return !(left == right); } @@ -887,6 +899,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MassMomentOfInertiaUnit)unit); + /// /// Convert to the unit representation . /// @@ -900,6 +914,8 @@ public double As(MassMomentOfInertiaUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MassMomentOfInertiaUnit) unit); + /// /// Converts this MassMomentOfInertia to another MassMomentOfInertia with the unit representation . /// @@ -910,6 +926,10 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit) return new MassMomentOfInertia(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MassMomentOfInertiaUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MassMomentOfInertiaUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs index dfa6b62b6d..5e3759ff41 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct MolarEnergy : IQuantity, IEquatable(QuantityType.MolarEnergy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public MolarEnergy(double numericValue, MolarEnergyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public MolarEnergy(double numericValue, MolarEnergyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out MolarE return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MolarEnergy left, MolarEnergy right) + public static bool operator ==(MolarEnergy left, MolarEnergy right) { return left.Equals(right); } - public static bool operator !=(MolarEnergy left, MolarEnergy right) + public static bool operator !=(MolarEnergy left, MolarEnergy right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MolarEnergyUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(MolarEnergyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MolarEnergyUnit) unit); + /// /// Converts this MolarEnergy to another MolarEnergy with the unit representation . /// @@ -560,6 +576,10 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit) return new MolarEnergy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MolarEnergyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MolarEnergyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs index fd1a3c6263..afe4050a9d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct MolarEntropy : IQuantity, IEquatable(QuantityType.MolarEntropy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public MolarEntropy(double numericValue, MolarEntropyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public MolarEntropy(double numericValue, MolarEntropyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out MolarE return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MolarEntropy left, MolarEntropy right) + public static bool operator ==(MolarEntropy left, MolarEntropy right) { return left.Equals(right); } - public static bool operator !=(MolarEntropy left, MolarEntropy right) + public static bool operator !=(MolarEntropy left, MolarEntropy right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MolarEntropyUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(MolarEntropyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MolarEntropyUnit) unit); + /// /// Converts this MolarEntropy to another MolarEntropy with the unit representation . /// @@ -560,6 +576,10 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit) return new MolarEntropy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MolarEntropyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MolarEntropyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs index 4721d8b907..bee2782b73 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct MolarMass : IQuantity, IEquatable(QuantityType.MolarMass, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public MolarMass(double numericValue, MolarMassUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public MolarMass(double numericValue, MolarMassUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarMassUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -562,12 +574,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out MolarM return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(MolarMass left, MolarMass right) + public static bool operator ==(MolarMass left, MolarMass right) { return left.Equals(right); } - public static bool operator !=(MolarMass left, MolarMass right) + public static bool operator !=(MolarMass left, MolarMass right) { return !(left == right); } @@ -663,6 +675,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MolarMassUnit)unit); + /// /// Convert to the unit representation . /// @@ -676,6 +690,8 @@ public double As(MolarMassUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MolarMassUnit) unit); + /// /// Converts this MolarMass to another MolarMass with the unit representation . /// @@ -686,6 +702,10 @@ public MolarMass ToUnit(MolarMassUnit unit) return new MolarMass(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MolarMassUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MolarMassUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs index 9094636403..918011e751 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Molarity : IQuantity, IEquatable, static Molarity() { BaseDimensions = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0); + Info = new QuantityInfo(QuantityType.Molarity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Molarity(double numericValue, MolarityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Molarity(double numericValue, MolarityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public MolarityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -509,12 +521,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Molari return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Molarity left, Molarity right) + public static bool operator ==(Molarity left, Molarity right) { return left.Equals(right); } - public static bool operator !=(Molarity left, Molarity right) + public static bool operator !=(Molarity left, Molarity right) { return !(left == right); } @@ -610,6 +622,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((MolarityUnit)unit); + /// /// Convert to the unit representation . /// @@ -623,6 +637,8 @@ public double As(MolarityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((MolarityUnit) unit); + /// /// Converts this Molarity to another Molarity with the unit representation . /// @@ -633,6 +649,10 @@ public Molarity ToUnit(MolarityUnit unit) return new Molarity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(MolarityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((MolarityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs index 02ab452db7..0321154550 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Permeability : IQuantity, IEquatable(QuantityType.Permeability, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Permeability(double numericValue, PermeabilityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Permeability(double numericValue, PermeabilityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PermeabilityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Permea return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Permeability left, Permeability right) + public static bool operator ==(Permeability left, Permeability right) { return left.Equals(right); } - public static bool operator !=(Permeability left, Permeability right) + public static bool operator !=(Permeability left, Permeability right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((PermeabilityUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(PermeabilityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((PermeabilityUnit) unit); + /// /// Converts this Permeability to another Permeability with the unit representation . /// @@ -535,6 +551,10 @@ public Permeability ToUnit(PermeabilityUnit unit) return new Permeability(convertedValue, unit); } + IQuantity IQuantity.ToUnit(PermeabilityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((PermeabilityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs index 1e70c4a242..32c2843e0b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct Permittivity : IQuantity, IEquatable(QuantityType.Permittivity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public Permittivity(double numericValue, PermittivityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public Permittivity(double numericValue, PermittivityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PermittivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Permit return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Permittivity left, Permittivity right) + public static bool operator ==(Permittivity left, Permittivity right) { return left.Equals(right); } - public static bool operator !=(Permittivity left, Permittivity right) + public static bool operator !=(Permittivity left, Permittivity right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((PermittivityUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(PermittivityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((PermittivityUnit) unit); + /// /// Converts this Permittivity to another Permittivity with the unit representation . /// @@ -535,6 +551,10 @@ public Permittivity ToUnit(PermittivityUnit unit) return new Permittivity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(PermittivityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((PermittivityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs index 18faeda9a1..426d220b85 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Power : IQuantity, IEquatable, IComparab static Power() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Power, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Power(decimal numericValue, PowerUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Power(decimal numericValue, PowerUnit unit) /// public decimal Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -674,12 +686,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out PowerU return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Power left, Power right) + public static bool operator ==(Power left, Power right) { return left.Equals(right); } - public static bool operator !=(Power left, Power right) + public static bool operator !=(Power left, Power right) { return !(left == right); } @@ -775,6 +787,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((PowerUnit)unit); + /// /// Convert to the unit representation . /// @@ -788,6 +802,8 @@ public double As(PowerUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((PowerUnit) unit); + /// /// Converts this Power to another Power with the unit representation . /// @@ -798,6 +814,10 @@ public Power ToUnit(PowerUnit unit) return new Power(convertedValue, unit); } + IQuantity IQuantity.ToUnit(PowerUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((PowerUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs index 9eba92a219..9ca7616e1e 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct PowerDensity : IQuantity, IEquatable(QuantityType.PowerDensity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public PowerDensity(double numericValue, PowerDensityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public PowerDensity(double numericValue, PowerDensityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PowerDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1010,12 +1022,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out PowerD return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(PowerDensity left, PowerDensity right) + public static bool operator ==(PowerDensity left, PowerDensity right) { return left.Equals(right); } - public static bool operator !=(PowerDensity left, PowerDensity right) + public static bool operator !=(PowerDensity left, PowerDensity right) { return !(left == right); } @@ -1111,6 +1123,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((PowerDensityUnit)unit); + /// /// Convert to the unit representation . /// @@ -1124,6 +1138,8 @@ public double As(PowerDensityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((PowerDensityUnit) unit); + /// /// Converts this PowerDensity to another PowerDensity with the unit representation . /// @@ -1134,6 +1150,10 @@ public PowerDensity ToUnit(PowerDensityUnit unit) return new PowerDensity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(PowerDensityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((PowerDensityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs index b3c113cf13..a7efeff4b9 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct PowerRatio : IQuantity, IEquatable(QuantityType.PowerRatio, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public PowerRatio(double numericValue, PowerRatioUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public PowerRatio(double numericValue, PowerRatioUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PowerRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -430,12 +442,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out PowerR return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(PowerRatio left, PowerRatio right) + public static bool operator ==(PowerRatio left, PowerRatio right) { return left.Equals(right); } - public static bool operator !=(PowerRatio left, PowerRatio right) + public static bool operator !=(PowerRatio left, PowerRatio right) { return !(left == right); } @@ -531,6 +543,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((PowerRatioUnit)unit); + /// /// Convert to the unit representation . /// @@ -544,6 +558,8 @@ public double As(PowerRatioUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((PowerRatioUnit) unit); + /// /// Converts this PowerRatio to another PowerRatio with the unit representation . /// @@ -554,6 +570,10 @@ public PowerRatio ToUnit(PowerRatioUnit unit) return new PowerRatio(convertedValue, unit); } + IQuantity IQuantity.ToUnit(PowerRatioUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((PowerRatioUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs index 0d47de1c2a..819cbae23c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Pressure : IQuantity, IEquatable, static Pressure() { BaseDimensions = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Pressure, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Pressure(double numericValue, PressureUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Pressure(double numericValue, PressureUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PressureUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -982,12 +994,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Pressu return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Pressure left, Pressure right) + public static bool operator ==(Pressure left, Pressure right) { return left.Equals(right); } - public static bool operator !=(Pressure left, Pressure right) + public static bool operator !=(Pressure left, Pressure right) { return !(left == right); } @@ -1083,6 +1095,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((PressureUnit)unit); + /// /// Convert to the unit representation . /// @@ -1096,6 +1110,8 @@ public double As(PressureUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((PressureUnit) unit); + /// /// Converts this Pressure to another Pressure with the unit representation . /// @@ -1106,6 +1122,10 @@ public Pressure ToUnit(PressureUnit unit) return new Pressure(convertedValue, unit); } + IQuantity IQuantity.ToUnit(PressureUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((PressureUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs index 3bb2d8a080..a0abe4af27 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct PressureChangeRate : IQuantity, IE static PressureChangeRate() { BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.PressureChangeRate, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public PressureChangeRate(double numericValue, PressureChangeRateUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public PressureChangeRate(double numericValue, PressureChangeRateUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public PressureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -492,12 +504,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Pressu return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(PressureChangeRate left, PressureChangeRate right) + public static bool operator ==(PressureChangeRate left, PressureChangeRate right) { return left.Equals(right); } - public static bool operator !=(PressureChangeRate left, PressureChangeRate right) + public static bool operator !=(PressureChangeRate left, PressureChangeRate right) { return !(left == right); } @@ -593,6 +605,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((PressureChangeRateUnit)unit); + /// /// Convert to the unit representation . /// @@ -606,6 +620,8 @@ public double As(PressureChangeRateUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((PressureChangeRateUnit) unit); + /// /// Converts this PressureChangeRate to another PressureChangeRate with the unit representation . /// @@ -616,6 +632,10 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit) return new PressureChangeRate(convertedValue, unit); } + IQuantity IQuantity.ToUnit(PressureChangeRateUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((PressureChangeRateUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs index cd4a096efc..5f33c5fbd5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Ratio : IQuantity, IEquatable, IComparab static Ratio() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.Ratio, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Ratio(double numericValue, RatioUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Ratio(double numericValue, RatioUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -478,12 +490,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out RatioU return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Ratio left, Ratio right) + public static bool operator ==(Ratio left, Ratio right) { return left.Equals(right); } - public static bool operator !=(Ratio left, Ratio right) + public static bool operator !=(Ratio left, Ratio right) { return !(left == right); } @@ -579,6 +591,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((RatioUnit)unit); + /// /// Convert to the unit representation . /// @@ -592,6 +606,8 @@ public double As(RatioUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((RatioUnit) unit); + /// /// Converts this Ratio to another Ratio with the unit representation . /// @@ -602,6 +618,10 @@ public Ratio ToUnit(RatioUnit unit) return new Ratio(convertedValue, unit); } + IQuantity IQuantity.ToUnit(RatioUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((RatioUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs index 9b994dd9b5..e940fad26c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ReactiveEnergy : IQuantity, IEquatable static ReactiveEnergy() { BaseDimensions = new BaseDimensions(2, 1, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.ReactiveEnergy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ReactiveEnergy(double numericValue, ReactiveEnergyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ReactiveEnergy(double numericValue, ReactiveEnergyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ReactiveEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Reacti return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) + public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) { return left.Equals(right); } - public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) + public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ReactiveEnergyUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(ReactiveEnergyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ReactiveEnergyUnit) unit); + /// /// Converts this ReactiveEnergy to another ReactiveEnergy with the unit representation . /// @@ -560,6 +576,10 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit) return new ReactiveEnergy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ReactiveEnergyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ReactiveEnergyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs index f96d7f69f9..5c200bd57a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ReactivePower : IQuantity, IEquatable(QuantityType.ReactivePower, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ReactivePower(double numericValue, ReactivePowerUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ReactivePower(double numericValue, ReactivePowerUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ReactivePowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -450,12 +462,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Reacti return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ReactivePower left, ReactivePower right) + public static bool operator ==(ReactivePower left, ReactivePower right) { return left.Equals(right); } - public static bool operator !=(ReactivePower left, ReactivePower right) + public static bool operator !=(ReactivePower left, ReactivePower right) { return !(left == right); } @@ -551,6 +563,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ReactivePowerUnit)unit); + /// /// Convert to the unit representation . /// @@ -564,6 +578,8 @@ public double As(ReactivePowerUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ReactivePowerUnit) unit); + /// /// Converts this ReactivePower to another ReactivePower with the unit representation . /// @@ -574,6 +590,10 @@ public ReactivePower ToUnit(ReactivePowerUnit unit) return new ReactivePower(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ReactivePowerUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ReactivePowerUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs index 54f5c82f10..a3a9a32cb6 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct RotationalAcceleration : IQuantity(QuantityType.RotationalAcceleration, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public RotationalAcceleration(double numericValue, RotationalAccelerationUnit un #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public RotationalAcceleration(double numericValue, RotationalAccelerationUnit un /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalAccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Rotati return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) + public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) { return left.Equals(right); } - public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) + public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((RotationalAccelerationUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(RotationalAccelerationUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((RotationalAccelerationUnit) unit); + /// /// Converts this RotationalAcceleration to another RotationalAcceleration with the unit representation . /// @@ -560,6 +576,10 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit) return new RotationalAcceleration(convertedValue, unit); } + IQuantity IQuantity.ToUnit(RotationalAccelerationUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((RotationalAccelerationUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs index c516604501..af863246f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct RotationalSpeed : IQuantity, IEquatab static RotationalSpeed() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.RotationalSpeed, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public RotationalSpeed(double numericValue, RotationalSpeedUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public RotationalSpeed(double numericValue, RotationalSpeedUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalSpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -576,12 +588,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Rotati return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(RotationalSpeed left, RotationalSpeed right) + public static bool operator ==(RotationalSpeed left, RotationalSpeed right) { return left.Equals(right); } - public static bool operator !=(RotationalSpeed left, RotationalSpeed right) + public static bool operator !=(RotationalSpeed left, RotationalSpeed right) { return !(left == right); } @@ -677,6 +689,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((RotationalSpeedUnit)unit); + /// /// Convert to the unit representation . /// @@ -690,6 +704,8 @@ public double As(RotationalSpeedUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((RotationalSpeedUnit) unit); + /// /// Converts this RotationalSpeed to another RotationalSpeed with the unit representation . /// @@ -700,6 +716,10 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit) return new RotationalSpeed(convertedValue, unit); } + IQuantity IQuantity.ToUnit(RotationalSpeedUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((RotationalSpeedUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs index 06f27db81a..bbcc009068 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct RotationalStiffness : IQuantity, static RotationalStiffness() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.RotationalStiffness, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public RotationalStiffness(double numericValue, RotationalStiffnessUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public RotationalStiffness(double numericValue, RotationalStiffnessUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalStiffnessUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Rotati return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(RotationalStiffness left, RotationalStiffness right) + public static bool operator ==(RotationalStiffness left, RotationalStiffness right) { return left.Equals(right); } - public static bool operator !=(RotationalStiffness left, RotationalStiffness right) + public static bool operator !=(RotationalStiffness left, RotationalStiffness right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((RotationalStiffnessUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(RotationalStiffnessUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((RotationalStiffnessUnit) unit); + /// /// Converts this RotationalStiffness to another RotationalStiffness with the unit representation . /// @@ -560,6 +576,10 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit) return new RotationalStiffness(convertedValue, unit); } + IQuantity IQuantity.ToUnit(RotationalStiffnessUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((RotationalStiffnessUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs index ff246b845e..b4a9256e45 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct RotationalStiffnessPerLength : IQuantity(QuantityType.RotationalStiffnessPerLength, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public RotationalStiffnessPerLength(double numericValue, RotationalStiffnessPerL #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public RotationalStiffnessPerLength(double numericValue, RotationalStiffnessPerL /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public RotationalStiffnessPerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Rotati return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return left.Equals(right); } - public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((RotationalStiffnessPerLengthUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(RotationalStiffnessPerLengthUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((RotationalStiffnessPerLengthUnit) unit); + /// /// Converts this RotationalStiffnessPerLength to another RotationalStiffnessPerLength with the unit representation . /// @@ -560,6 +576,10 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit return new RotationalStiffnessPerLength(convertedValue, unit); } + IQuantity IQuantity.ToUnit(RotationalStiffnessPerLengthUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((RotationalStiffnessPerLengthUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs index 0c2249eac2..71b605d956 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct SolidAngle : IQuantity, IEquatable(QuantityType.SolidAngle, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public SolidAngle(double numericValue, SolidAngleUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public SolidAngle(double numericValue, SolidAngleUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SolidAngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -411,12 +423,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out SolidA return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(SolidAngle left, SolidAngle right) + public static bool operator ==(SolidAngle left, SolidAngle right) { return left.Equals(right); } - public static bool operator !=(SolidAngle left, SolidAngle right) + public static bool operator !=(SolidAngle left, SolidAngle right) { return !(left == right); } @@ -512,6 +524,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((SolidAngleUnit)unit); + /// /// Convert to the unit representation . /// @@ -525,6 +539,8 @@ public double As(SolidAngleUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((SolidAngleUnit) unit); + /// /// Converts this SolidAngle to another SolidAngle with the unit representation . /// @@ -535,6 +551,10 @@ public SolidAngle ToUnit(SolidAngleUnit unit) return new SolidAngle(convertedValue, unit); } + IQuantity IQuantity.ToUnit(SolidAngleUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((SolidAngleUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs index 73bf333040..2bb673bf75 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct SpecificEnergy : IQuantity, IEquatable static SpecificEnergy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificEnergy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public SpecificEnergy(double numericValue, SpecificEnergyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public SpecificEnergy(double numericValue, SpecificEnergyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -523,12 +535,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Specif return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(SpecificEnergy left, SpecificEnergy right) + public static bool operator ==(SpecificEnergy left, SpecificEnergy right) { return left.Equals(right); } - public static bool operator !=(SpecificEnergy left, SpecificEnergy right) + public static bool operator !=(SpecificEnergy left, SpecificEnergy right) { return !(left == right); } @@ -624,6 +636,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((SpecificEnergyUnit)unit); + /// /// Convert to the unit representation . /// @@ -637,6 +651,8 @@ public double As(SpecificEnergyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((SpecificEnergyUnit) unit); + /// /// Converts this SpecificEnergy to another SpecificEnergy with the unit representation . /// @@ -647,6 +663,10 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit) return new SpecificEnergy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(SpecificEnergyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((SpecificEnergyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs index 71da6779bb..01b8338fa5 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct SpecificEntropy : IQuantity, IEquatab static SpecificEntropy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificEntropy, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public SpecificEntropy(double numericValue, SpecificEntropyUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public SpecificEntropy(double numericValue, SpecificEntropyUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -506,12 +518,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Specif return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(SpecificEntropy left, SpecificEntropy right) + public static bool operator ==(SpecificEntropy left, SpecificEntropy right) { return left.Equals(right); } - public static bool operator !=(SpecificEntropy left, SpecificEntropy right) + public static bool operator !=(SpecificEntropy left, SpecificEntropy right) { return !(left == right); } @@ -607,6 +619,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((SpecificEntropyUnit)unit); + /// /// Convert to the unit representation . /// @@ -620,6 +634,8 @@ public double As(SpecificEntropyUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((SpecificEntropyUnit) unit); + /// /// Converts this SpecificEntropy to another SpecificEntropy with the unit representation . /// @@ -630,6 +646,10 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit) return new SpecificEntropy(convertedValue, unit); } + IQuantity IQuantity.ToUnit(SpecificEntropyUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((SpecificEntropyUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs index fc308ee2d8..a2f0f2784a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct SpecificVolume : IQuantity, IEquatable static SpecificVolume() { BaseDimensions = new BaseDimensions(3, -1, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificVolume, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public SpecificVolume(double numericValue, SpecificVolumeUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public SpecificVolume(double numericValue, SpecificVolumeUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificVolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -436,12 +448,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Specif return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(SpecificVolume left, SpecificVolume right) + public static bool operator ==(SpecificVolume left, SpecificVolume right) { return left.Equals(right); } - public static bool operator !=(SpecificVolume left, SpecificVolume right) + public static bool operator !=(SpecificVolume left, SpecificVolume right) { return !(left == right); } @@ -537,6 +549,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((SpecificVolumeUnit)unit); + /// /// Convert to the unit representation . /// @@ -550,6 +564,8 @@ public double As(SpecificVolumeUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((SpecificVolumeUnit) unit); + /// /// Converts this SpecificVolume to another SpecificVolume with the unit representation . /// @@ -560,6 +576,10 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit) return new SpecificVolume(convertedValue, unit); } + IQuantity IQuantity.ToUnit(SpecificVolumeUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((SpecificVolumeUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs index 919f43f045..dd8ca5f15b 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct SpecificWeight : IQuantity, IEquatable static SpecificWeight() { BaseDimensions = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.SpecificWeight, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public SpecificWeight(double numericValue, SpecificWeightUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public SpecificWeight(double numericValue, SpecificWeightUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpecificWeightUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -635,12 +647,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Specif return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(SpecificWeight left, SpecificWeight right) + public static bool operator ==(SpecificWeight left, SpecificWeight right) { return left.Equals(right); } - public static bool operator !=(SpecificWeight left, SpecificWeight right) + public static bool operator !=(SpecificWeight left, SpecificWeight right) { return !(left == right); } @@ -736,6 +748,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((SpecificWeightUnit)unit); + /// /// Convert to the unit representation . /// @@ -749,6 +763,8 @@ public double As(SpecificWeightUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((SpecificWeightUnit) unit); + /// /// Converts this SpecificWeight to another SpecificWeight with the unit representation . /// @@ -759,6 +775,10 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit) return new SpecificWeight(convertedValue, unit); } + IQuantity IQuantity.ToUnit(SpecificWeightUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((SpecificWeightUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs index 9a3f4a5cc2..80ab533db3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Speed : IQuantity, IEquatable, IComparab static Speed() { BaseDimensions = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Speed, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Speed(double numericValue, SpeedUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Speed(double numericValue, SpeedUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public SpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -842,12 +854,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out SpeedU return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Speed left, Speed right) + public static bool operator ==(Speed left, Speed right) { return left.Equals(right); } - public static bool operator !=(Speed left, Speed right) + public static bool operator !=(Speed left, Speed right) { return !(left == right); } @@ -943,6 +955,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((SpeedUnit)unit); + /// /// Convert to the unit representation . /// @@ -956,6 +970,8 @@ public double As(SpeedUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((SpeedUnit) unit); + /// /// Converts this Speed to another Speed with the unit representation . /// @@ -966,6 +982,10 @@ public Speed ToUnit(SpeedUnit unit) return new Speed(convertedValue, unit); } + IQuantity IQuantity.ToUnit(SpeedUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((SpeedUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs index db0438e785..d30449f131 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Temperature : IQuantity, IEquatable(QuantityType.Temperature, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Temperature(double numericValue, TemperatureUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Temperature(double numericValue, TemperatureUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TemperatureUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -467,12 +479,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Temper return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Temperature left, Temperature right) + public static bool operator ==(Temperature left, Temperature right) { return left.Equals(right); } - public static bool operator !=(Temperature left, Temperature right) + public static bool operator !=(Temperature left, Temperature right) { return !(left == right); } @@ -568,6 +580,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((TemperatureUnit)unit); + /// /// Convert to the unit representation . /// @@ -581,6 +595,8 @@ public double As(TemperatureUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((TemperatureUnit) unit); + /// /// Converts this Temperature to another Temperature with the unit representation . /// @@ -591,6 +607,10 @@ public Temperature ToUnit(TemperatureUnit unit) return new Temperature(convertedValue, unit); } + IQuantity IQuantity.ToUnit(TemperatureUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((TemperatureUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs index 0a5d7ac439..d69ec40bf3 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct TemperatureChangeRate : IQuantity(QuantityType.TemperatureChangeRate, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public TemperatureChangeRate(double numericValue, TemperatureChangeRateUnit unit #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public TemperatureChangeRate(double numericValue, TemperatureChangeRateUnit unit /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TemperatureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -534,12 +546,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Temper return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) + public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) { return left.Equals(right); } - public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) + public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) { return !(left == right); } @@ -635,6 +647,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((TemperatureChangeRateUnit)unit); + /// /// Convert to the unit representation . /// @@ -648,6 +662,8 @@ public double As(TemperatureChangeRateUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((TemperatureChangeRateUnit) unit); + /// /// Converts this TemperatureChangeRate to another TemperatureChangeRate with the unit representation . /// @@ -658,6 +674,10 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit) return new TemperatureChangeRate(convertedValue, unit); } + IQuantity IQuantity.ToUnit(TemperatureChangeRateUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((TemperatureChangeRateUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs index 84fe4d07aa..9adcf7ed0c 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct TemperatureDelta : IQuantity, IEquat static TemperatureDelta() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.TemperatureDelta, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public TemperatureDelta(double numericValue, TemperatureDeltaUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public TemperatureDelta(double numericValue, TemperatureDeltaUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TemperatureDeltaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -506,12 +518,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Temper return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(TemperatureDelta left, TemperatureDelta right) + public static bool operator ==(TemperatureDelta left, TemperatureDelta right) { return left.Equals(right); } - public static bool operator !=(TemperatureDelta left, TemperatureDelta right) + public static bool operator !=(TemperatureDelta left, TemperatureDelta right) { return !(left == right); } @@ -607,6 +619,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((TemperatureDeltaUnit)unit); + /// /// Convert to the unit representation . /// @@ -620,6 +634,8 @@ public double As(TemperatureDeltaUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((TemperatureDeltaUnit) unit); + /// /// Converts this TemperatureDelta to another TemperatureDelta with the unit representation . /// @@ -630,6 +646,10 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit) return new TemperatureDelta(convertedValue, unit); } + IQuantity IQuantity.ToUnit(TemperatureDeltaUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((TemperatureDeltaUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs index a722655da4..b138887f40 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.NetFramework.g.cs @@ -67,6 +67,7 @@ public partial struct ThermalConductivity : IQuantity, static ThermalConductivity() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, -1, 0, 0); + Info = new QuantityInfo(QuantityType.ThermalConductivity, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -87,6 +88,9 @@ public ThermalConductivity(double numericValue, ThermalConductivityUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -131,11 +135,19 @@ public ThermalConductivity(double numericValue, ThermalConductivityUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ThermalConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -425,12 +437,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Therma return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ThermalConductivity left, ThermalConductivity right) + public static bool operator ==(ThermalConductivity left, ThermalConductivity right) { return left.Equals(right); } - public static bool operator !=(ThermalConductivity left, ThermalConductivity right) + public static bool operator !=(ThermalConductivity left, ThermalConductivity right) { return !(left == right); } @@ -526,6 +538,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ThermalConductivityUnit)unit); + /// /// Convert to the unit representation . /// @@ -539,6 +553,8 @@ public double As(ThermalConductivityUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ThermalConductivityUnit) unit); + /// /// Converts this ThermalConductivity to another ThermalConductivity with the unit representation . /// @@ -549,6 +565,10 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit) return new ThermalConductivity(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ThermalConductivityUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ThermalConductivityUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs index d5f8841be7..8352a9476b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct ThermalResistance : IQuantity, IEqu static ThermalResistance() { BaseDimensions = new BaseDimensions(0, -1, 3, 0, 1, 0, 0); + Info = new QuantityInfo(QuantityType.ThermalResistance, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public ThermalResistance(double numericValue, ThermalResistanceUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public ThermalResistance(double numericValue, ThermalResistanceUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public ThermalResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -464,12 +476,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Therma return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(ThermalResistance left, ThermalResistance right) + public static bool operator ==(ThermalResistance left, ThermalResistance right) { return left.Equals(right); } - public static bool operator !=(ThermalResistance left, ThermalResistance right) + public static bool operator !=(ThermalResistance left, ThermalResistance right) { return !(left == right); } @@ -565,6 +577,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((ThermalResistanceUnit)unit); + /// /// Convert to the unit representation . /// @@ -578,6 +592,8 @@ public double As(ThermalResistanceUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((ThermalResistanceUnit) unit); + /// /// Converts this ThermalResistance to another ThermalResistance with the unit representation . /// @@ -588,6 +604,10 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit) return new ThermalResistance(convertedValue, unit); } + IQuantity IQuantity.ToUnit(ThermalResistanceUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((ThermalResistanceUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs index 322b8cad4c..6ebe666abd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Torque : IQuantity, IEquatable, ICompa static Torque() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Torque, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Torque(double numericValue, TorqueUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Torque(double numericValue, TorqueUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public TorqueUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -688,12 +700,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Torque return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Torque left, Torque right) + public static bool operator ==(Torque left, Torque right) { return left.Equals(right); } - public static bool operator !=(Torque left, Torque right) + public static bool operator !=(Torque left, Torque right) { return !(left == right); } @@ -789,6 +801,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((TorqueUnit)unit); + /// /// Convert to the unit representation . /// @@ -802,6 +816,8 @@ public double As(TorqueUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((TorqueUnit) unit); + /// /// Converts this Torque to another Torque with the unit representation . /// @@ -812,6 +828,10 @@ public Torque ToUnit(TorqueUnit unit) return new Torque(convertedValue, unit); } + IQuantity IQuantity.ToUnit(TorqueUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((TorqueUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs index 85a7585a8a..25a8d5de2b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct VitaminA : IQuantity, IEquatable, static VitaminA() { BaseDimensions = BaseDimensions.Dimensionless; + Info = new QuantityInfo(QuantityType.VitaminA, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public VitaminA(double numericValue, VitaminAUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public VitaminA(double numericValue, VitaminAUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public VitaminAUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -408,12 +420,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Vitami return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(VitaminA left, VitaminA right) + public static bool operator ==(VitaminA left, VitaminA right) { return left.Equals(right); } - public static bool operator !=(VitaminA left, VitaminA right) + public static bool operator !=(VitaminA left, VitaminA right) { return !(left == right); } @@ -509,6 +521,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((VitaminAUnit)unit); + /// /// Convert to the unit representation . /// @@ -522,6 +536,8 @@ public double As(VitaminAUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((VitaminAUnit) unit); + /// /// Converts this VitaminA to another VitaminA with the unit representation . /// @@ -532,6 +548,10 @@ public VitaminA ToUnit(VitaminAUnit unit) return new VitaminA(convertedValue, unit); } + IQuantity IQuantity.ToUnit(VitaminAUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((VitaminAUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs index d77f36c23c..524a7162ba 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct Volume : IQuantity, IEquatable, ICompa static Volume() { BaseDimensions = new BaseDimensions(3, 0, 0, 0, 0, 0, 0); + Info = new QuantityInfo(QuantityType.Volume, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public Volume(double numericValue, VolumeUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public Volume(double numericValue, VolumeUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public VolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1024,12 +1036,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Volume return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(Volume left, Volume right) + public static bool operator ==(Volume left, Volume right) { return left.Equals(right); } - public static bool operator !=(Volume left, Volume right) + public static bool operator !=(Volume left, Volume right) { return !(left == right); } @@ -1125,6 +1137,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((VolumeUnit)unit); + /// /// Convert to the unit representation . /// @@ -1138,6 +1152,8 @@ public double As(VolumeUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((VolumeUnit) unit); + /// /// Converts this Volume to another Volume with the unit representation . /// @@ -1148,6 +1164,10 @@ public Volume ToUnit(VolumeUnit unit) return new Volume(convertedValue, unit); } + IQuantity IQuantity.ToUnit(VolumeUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((VolumeUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs index 701d37c3fc..e90b5426b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs @@ -64,6 +64,7 @@ public partial struct VolumeFlow : IQuantity, IEquatable(QuantityType.VolumeFlow, Units, BaseUnit, Zero, BaseDimensions); } /// @@ -84,6 +85,9 @@ public VolumeFlow(double numericValue, VolumeFlowUnit unit) #region Static Properties + /// + public static QuantityInfo Info { get; } + /// /// The of this quantity. /// @@ -128,11 +132,19 @@ public VolumeFlow(double numericValue, VolumeFlowUnit unit) /// public double Value => _value; + /// + Enum IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public VolumeFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + /// /// The of this quantity. /// @@ -1066,12 +1078,12 @@ public static bool TryParseUnit(string str, IFormatProvider provider, out Volume return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==(VolumeFlow left, VolumeFlow right) + public static bool operator ==(VolumeFlow left, VolumeFlow right) { return left.Equals(right); } - public static bool operator !=(VolumeFlow left, VolumeFlow right) + public static bool operator !=(VolumeFlow left, VolumeFlow right) { return !(left == right); } @@ -1167,6 +1179,8 @@ public override int GetHashCode() #region Conversion Methods + double IQuantity.As(Enum unit) => As((VolumeFlowUnit)unit); + /// /// Convert to the unit representation . /// @@ -1180,6 +1194,8 @@ public double As(VolumeFlowUnit unit) return Convert.ToDouble(converted); } + public double As(Enum unit) => As((VolumeFlowUnit) unit); + /// /// Converts this VolumeFlow to another VolumeFlow with the unit representation . /// @@ -1190,6 +1206,10 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit) return new VolumeFlow(convertedValue, unit); } + IQuantity IQuantity.ToUnit(VolumeFlowUnit unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit((VolumeFlowUnit) unit); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs new file mode 100644 index 0000000000..932a5b6975 --- /dev/null +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -0,0 +1,720 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). +// https://github.com/angularsen/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using JetBrains.Annotations; +using UnitsNet.InternalHelpers; +using UnitsNet.Units; + +#if WINDOWS_UWP +using FromValue = System.Double; +#else +using FromValue = UnitsNet.QuantityValue; +#endif + +namespace UnitsNet +{ + /// + /// Dynamically parse or construct quantities when types are only known at runtime. + /// +#if WINDOWS_UWP + internal +#else + public +#endif + static partial class Quantity + { +#if !WINDOWS_UWP + /// + public static bool TryFrom(double value, Enum unit, out IQuantity quantity) + { + // Implicit cast to FromValue would prevent TryFrom from being called, + // so we need to explicitly check this here for double arguments. + if (double.IsNaN(value) || double.IsInfinity(value)) + { + quantity = default(IQuantity); + return false; + } + + return TryFrom((FromValue) value, unit, out quantity); + } +#endif + + /// + /// Try to dynamically construct a quantity. + /// + /// Numeric value. + /// Unit enum value. + /// The resulting quantity if successful, otherwise default. + /// True if successful with assigned the value, otherwise false. +#if WINDOWS_UWP + internal +#else + public +#endif + static bool TryFrom(FromValue value, Enum unit, out IQuantity quantity) + { + switch (unit) + { + case AccelerationUnit accelerationUnit: + quantity = Acceleration.From(value, accelerationUnit); + return true; + case AmountOfSubstanceUnit amountOfSubstanceUnit: + quantity = AmountOfSubstance.From(value, amountOfSubstanceUnit); + return true; + case AmplitudeRatioUnit amplitudeRatioUnit: + quantity = AmplitudeRatio.From(value, amplitudeRatioUnit); + return true; + case AngleUnit angleUnit: + quantity = Angle.From(value, angleUnit); + return true; + case ApparentEnergyUnit apparentEnergyUnit: + quantity = ApparentEnergy.From(value, apparentEnergyUnit); + return true; + case ApparentPowerUnit apparentPowerUnit: + quantity = ApparentPower.From(value, apparentPowerUnit); + return true; + case AreaUnit areaUnit: + quantity = Area.From(value, areaUnit); + return true; + case AreaDensityUnit areaDensityUnit: + quantity = AreaDensity.From(value, areaDensityUnit); + return true; + case AreaMomentOfInertiaUnit areaMomentOfInertiaUnit: + quantity = AreaMomentOfInertia.From(value, areaMomentOfInertiaUnit); + return true; + case BitRateUnit bitRateUnit: + quantity = BitRate.From(value, bitRateUnit); + return true; + case BrakeSpecificFuelConsumptionUnit brakeSpecificFuelConsumptionUnit: + quantity = BrakeSpecificFuelConsumption.From(value, brakeSpecificFuelConsumptionUnit); + return true; + case CapacitanceUnit capacitanceUnit: + quantity = Capacitance.From(value, capacitanceUnit); + return true; + case CoefficientOfThermalExpansionUnit coefficientOfThermalExpansionUnit: + quantity = CoefficientOfThermalExpansion.From(value, coefficientOfThermalExpansionUnit); + return true; + case DensityUnit densityUnit: + quantity = Density.From(value, densityUnit); + return true; + case DurationUnit durationUnit: + quantity = Duration.From(value, durationUnit); + return true; + case DynamicViscosityUnit dynamicViscosityUnit: + quantity = DynamicViscosity.From(value, dynamicViscosityUnit); + return true; + case ElectricAdmittanceUnit electricAdmittanceUnit: + quantity = ElectricAdmittance.From(value, electricAdmittanceUnit); + return true; + case ElectricChargeUnit electricChargeUnit: + quantity = ElectricCharge.From(value, electricChargeUnit); + return true; + case ElectricChargeDensityUnit electricChargeDensityUnit: + quantity = ElectricChargeDensity.From(value, electricChargeDensityUnit); + return true; + case ElectricConductanceUnit electricConductanceUnit: + quantity = ElectricConductance.From(value, electricConductanceUnit); + return true; + case ElectricConductivityUnit electricConductivityUnit: + quantity = ElectricConductivity.From(value, electricConductivityUnit); + return true; + case ElectricCurrentUnit electricCurrentUnit: + quantity = ElectricCurrent.From(value, electricCurrentUnit); + return true; + case ElectricCurrentDensityUnit electricCurrentDensityUnit: + quantity = ElectricCurrentDensity.From(value, electricCurrentDensityUnit); + return true; + case ElectricCurrentGradientUnit electricCurrentGradientUnit: + quantity = ElectricCurrentGradient.From(value, electricCurrentGradientUnit); + return true; + case ElectricFieldUnit electricFieldUnit: + quantity = ElectricField.From(value, electricFieldUnit); + return true; + case ElectricInductanceUnit electricInductanceUnit: + quantity = ElectricInductance.From(value, electricInductanceUnit); + return true; + case ElectricPotentialUnit electricPotentialUnit: + quantity = ElectricPotential.From(value, electricPotentialUnit); + return true; + case ElectricPotentialAcUnit electricPotentialAcUnit: + quantity = ElectricPotentialAc.From(value, electricPotentialAcUnit); + return true; + case ElectricPotentialDcUnit electricPotentialDcUnit: + quantity = ElectricPotentialDc.From(value, electricPotentialDcUnit); + return true; + case ElectricResistanceUnit electricResistanceUnit: + quantity = ElectricResistance.From(value, electricResistanceUnit); + return true; + case ElectricResistivityUnit electricResistivityUnit: + quantity = ElectricResistivity.From(value, electricResistivityUnit); + return true; + case EnergyUnit energyUnit: + quantity = Energy.From(value, energyUnit); + return true; + case EntropyUnit entropyUnit: + quantity = Entropy.From(value, entropyUnit); + return true; + case ForceUnit forceUnit: + quantity = Force.From(value, forceUnit); + return true; + case ForceChangeRateUnit forceChangeRateUnit: + quantity = ForceChangeRate.From(value, forceChangeRateUnit); + return true; + case ForcePerLengthUnit forcePerLengthUnit: + quantity = ForcePerLength.From(value, forcePerLengthUnit); + return true; + case FrequencyUnit frequencyUnit: + quantity = Frequency.From(value, frequencyUnit); + return true; + case HeatFluxUnit heatFluxUnit: + quantity = HeatFlux.From(value, heatFluxUnit); + return true; + case HeatTransferCoefficientUnit heatTransferCoefficientUnit: + quantity = HeatTransferCoefficient.From(value, heatTransferCoefficientUnit); + return true; + case IlluminanceUnit illuminanceUnit: + quantity = Illuminance.From(value, illuminanceUnit); + return true; + case InformationUnit informationUnit: + quantity = Information.From(value, informationUnit); + return true; + case IrradianceUnit irradianceUnit: + quantity = Irradiance.From(value, irradianceUnit); + return true; + case IrradiationUnit irradiationUnit: + quantity = Irradiation.From(value, irradiationUnit); + return true; + case KinematicViscosityUnit kinematicViscosityUnit: + quantity = KinematicViscosity.From(value, kinematicViscosityUnit); + return true; + case LapseRateUnit lapseRateUnit: + quantity = LapseRate.From(value, lapseRateUnit); + return true; + case LengthUnit lengthUnit: + quantity = Length.From(value, lengthUnit); + return true; + case LevelUnit levelUnit: + quantity = Level.From(value, levelUnit); + return true; + case LinearDensityUnit linearDensityUnit: + quantity = LinearDensity.From(value, linearDensityUnit); + return true; + case LuminousFluxUnit luminousFluxUnit: + quantity = LuminousFlux.From(value, luminousFluxUnit); + return true; + case LuminousIntensityUnit luminousIntensityUnit: + quantity = LuminousIntensity.From(value, luminousIntensityUnit); + return true; + case MagneticFieldUnit magneticFieldUnit: + quantity = MagneticField.From(value, magneticFieldUnit); + return true; + case MagneticFluxUnit magneticFluxUnit: + quantity = MagneticFlux.From(value, magneticFluxUnit); + return true; + case MagnetizationUnit magnetizationUnit: + quantity = Magnetization.From(value, magnetizationUnit); + return true; + case MassUnit massUnit: + quantity = Mass.From(value, massUnit); + return true; + case MassFlowUnit massFlowUnit: + quantity = MassFlow.From(value, massFlowUnit); + return true; + case MassFluxUnit massFluxUnit: + quantity = MassFlux.From(value, massFluxUnit); + return true; + case MassMomentOfInertiaUnit massMomentOfInertiaUnit: + quantity = MassMomentOfInertia.From(value, massMomentOfInertiaUnit); + return true; + case MolarEnergyUnit molarEnergyUnit: + quantity = MolarEnergy.From(value, molarEnergyUnit); + return true; + case MolarEntropyUnit molarEntropyUnit: + quantity = MolarEntropy.From(value, molarEntropyUnit); + return true; + case MolarityUnit molarityUnit: + quantity = Molarity.From(value, molarityUnit); + return true; + case MolarMassUnit molarMassUnit: + quantity = MolarMass.From(value, molarMassUnit); + return true; + case PermeabilityUnit permeabilityUnit: + quantity = Permeability.From(value, permeabilityUnit); + return true; + case PermittivityUnit permittivityUnit: + quantity = Permittivity.From(value, permittivityUnit); + return true; + case PowerUnit powerUnit: + quantity = Power.From(value, powerUnit); + return true; + case PowerDensityUnit powerDensityUnit: + quantity = PowerDensity.From(value, powerDensityUnit); + return true; + case PowerRatioUnit powerRatioUnit: + quantity = PowerRatio.From(value, powerRatioUnit); + return true; + case PressureUnit pressureUnit: + quantity = Pressure.From(value, pressureUnit); + return true; + case PressureChangeRateUnit pressureChangeRateUnit: + quantity = PressureChangeRate.From(value, pressureChangeRateUnit); + return true; + case RatioUnit ratioUnit: + quantity = Ratio.From(value, ratioUnit); + return true; + case ReactiveEnergyUnit reactiveEnergyUnit: + quantity = ReactiveEnergy.From(value, reactiveEnergyUnit); + return true; + case ReactivePowerUnit reactivePowerUnit: + quantity = ReactivePower.From(value, reactivePowerUnit); + return true; + case RotationalAccelerationUnit rotationalAccelerationUnit: + quantity = RotationalAcceleration.From(value, rotationalAccelerationUnit); + return true; + case RotationalSpeedUnit rotationalSpeedUnit: + quantity = RotationalSpeed.From(value, rotationalSpeedUnit); + return true; + case RotationalStiffnessUnit rotationalStiffnessUnit: + quantity = RotationalStiffness.From(value, rotationalStiffnessUnit); + return true; + case RotationalStiffnessPerLengthUnit rotationalStiffnessPerLengthUnit: + quantity = RotationalStiffnessPerLength.From(value, rotationalStiffnessPerLengthUnit); + return true; + case SolidAngleUnit solidAngleUnit: + quantity = SolidAngle.From(value, solidAngleUnit); + return true; + case SpecificEnergyUnit specificEnergyUnit: + quantity = SpecificEnergy.From(value, specificEnergyUnit); + return true; + case SpecificEntropyUnit specificEntropyUnit: + quantity = SpecificEntropy.From(value, specificEntropyUnit); + return true; + case SpecificVolumeUnit specificVolumeUnit: + quantity = SpecificVolume.From(value, specificVolumeUnit); + return true; + case SpecificWeightUnit specificWeightUnit: + quantity = SpecificWeight.From(value, specificWeightUnit); + return true; + case SpeedUnit speedUnit: + quantity = Speed.From(value, speedUnit); + return true; + case TemperatureUnit temperatureUnit: + quantity = Temperature.From(value, temperatureUnit); + return true; + case TemperatureChangeRateUnit temperatureChangeRateUnit: + quantity = TemperatureChangeRate.From(value, temperatureChangeRateUnit); + return true; + case TemperatureDeltaUnit temperatureDeltaUnit: + quantity = TemperatureDelta.From(value, temperatureDeltaUnit); + return true; + case ThermalConductivityUnit thermalConductivityUnit: + quantity = ThermalConductivity.From(value, thermalConductivityUnit); + return true; + case ThermalResistanceUnit thermalResistanceUnit: + quantity = ThermalResistance.From(value, thermalResistanceUnit); + return true; + case TorqueUnit torqueUnit: + quantity = Torque.From(value, torqueUnit); + return true; + case VitaminAUnit vitaminAUnit: + quantity = VitaminA.From(value, vitaminAUnit); + return true; + case VolumeUnit volumeUnit: + quantity = Volume.From(value, volumeUnit); + return true; + case VolumeFlowUnit volumeFlowUnit: + quantity = VolumeFlow.From(value, volumeFlowUnit); + return true; + default: + { + quantity = default(IQuantity); + return false; + } + } + } + + /// +#if WINDOWS_UWP + internal +#else + public +#endif + static IQuantity Parse(Type quantityType, string quantityString) => Parse(null, quantityType, quantityString); + + /// + /// Dynamically parse a quantity string representation. + /// + /// The format provider to use for lookup. Defaults to if null. + /// Type of quantity, such as . + /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. + /// The parsed quantity. + /// Type must be of type UnitsNet.IQuantity -or- Type is not a known quantity type. +#if WINDOWS_UWP + internal +#else + public +#endif + static IQuantity Parse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString) + { + if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + throw new ArgumentException($"Type {quantityType} must be of type UnitsNet.IQuantity."); + + if (TryParse(formatProvider, quantityType, quantityString, out IQuantity quantity)) return quantity; + + throw new ArgumentException($"Quantity string could not be parsed to quantity {quantityType}."); + } + + /// +#if WINDOWS_UWP + internal +#else + public +#endif + static bool TryParse(Type quantityType, string quantityString, out IQuantity quantity) => + TryParse(null, quantityType, quantityString, out quantity); + + /// + /// Try to dynamically parse a quantity string representation. + /// + /// The format provider to use for lookup. Defaults to if null. + /// Type of quantity, such as . + /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. + /// The resulting quantity if successful, otherwise default. + /// The parsed quantity. +#if WINDOWS_UWP + internal +#else + public +#endif + static bool TryParse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString, out IQuantity quantity) + { + quantity = default(IQuantity); + + if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + return false; + + var parser = QuantityParser.Default; + + if (quantityType == typeof(Acceleration)) + return parser.TryParse(quantityString, formatProvider, Acceleration.From, out quantity); + + if (quantityType == typeof(AmountOfSubstance)) + return parser.TryParse(quantityString, formatProvider, AmountOfSubstance.From, out quantity); + + if (quantityType == typeof(AmplitudeRatio)) + return parser.TryParse(quantityString, formatProvider, AmplitudeRatio.From, out quantity); + + if (quantityType == typeof(Angle)) + return parser.TryParse(quantityString, formatProvider, Angle.From, out quantity); + + if (quantityType == typeof(ApparentEnergy)) + return parser.TryParse(quantityString, formatProvider, ApparentEnergy.From, out quantity); + + if (quantityType == typeof(ApparentPower)) + return parser.TryParse(quantityString, formatProvider, ApparentPower.From, out quantity); + + if (quantityType == typeof(Area)) + return parser.TryParse(quantityString, formatProvider, Area.From, out quantity); + + if (quantityType == typeof(AreaDensity)) + return parser.TryParse(quantityString, formatProvider, AreaDensity.From, out quantity); + + if (quantityType == typeof(AreaMomentOfInertia)) + return parser.TryParse(quantityString, formatProvider, AreaMomentOfInertia.From, out quantity); + + if (quantityType == typeof(BitRate)) + return parser.TryParse(quantityString, formatProvider, BitRate.From, out quantity); + + if (quantityType == typeof(BrakeSpecificFuelConsumption)) + return parser.TryParse(quantityString, formatProvider, BrakeSpecificFuelConsumption.From, out quantity); + + if (quantityType == typeof(Capacitance)) + return parser.TryParse(quantityString, formatProvider, Capacitance.From, out quantity); + + if (quantityType == typeof(CoefficientOfThermalExpansion)) + return parser.TryParse(quantityString, formatProvider, CoefficientOfThermalExpansion.From, out quantity); + + if (quantityType == typeof(Density)) + return parser.TryParse(quantityString, formatProvider, Density.From, out quantity); + + if (quantityType == typeof(Duration)) + return parser.TryParse(quantityString, formatProvider, Duration.From, out quantity); + + if (quantityType == typeof(DynamicViscosity)) + return parser.TryParse(quantityString, formatProvider, DynamicViscosity.From, out quantity); + + if (quantityType == typeof(ElectricAdmittance)) + return parser.TryParse(quantityString, formatProvider, ElectricAdmittance.From, out quantity); + + if (quantityType == typeof(ElectricCharge)) + return parser.TryParse(quantityString, formatProvider, ElectricCharge.From, out quantity); + + if (quantityType == typeof(ElectricChargeDensity)) + return parser.TryParse(quantityString, formatProvider, ElectricChargeDensity.From, out quantity); + + if (quantityType == typeof(ElectricConductance)) + return parser.TryParse(quantityString, formatProvider, ElectricConductance.From, out quantity); + + if (quantityType == typeof(ElectricConductivity)) + return parser.TryParse(quantityString, formatProvider, ElectricConductivity.From, out quantity); + + if (quantityType == typeof(ElectricCurrent)) + return parser.TryParse(quantityString, formatProvider, ElectricCurrent.From, out quantity); + + if (quantityType == typeof(ElectricCurrentDensity)) + return parser.TryParse(quantityString, formatProvider, ElectricCurrentDensity.From, out quantity); + + if (quantityType == typeof(ElectricCurrentGradient)) + return parser.TryParse(quantityString, formatProvider, ElectricCurrentGradient.From, out quantity); + + if (quantityType == typeof(ElectricField)) + return parser.TryParse(quantityString, formatProvider, ElectricField.From, out quantity); + + if (quantityType == typeof(ElectricInductance)) + return parser.TryParse(quantityString, formatProvider, ElectricInductance.From, out quantity); + + if (quantityType == typeof(ElectricPotential)) + return parser.TryParse(quantityString, formatProvider, ElectricPotential.From, out quantity); + + if (quantityType == typeof(ElectricPotentialAc)) + return parser.TryParse(quantityString, formatProvider, ElectricPotentialAc.From, out quantity); + + if (quantityType == typeof(ElectricPotentialDc)) + return parser.TryParse(quantityString, formatProvider, ElectricPotentialDc.From, out quantity); + + if (quantityType == typeof(ElectricResistance)) + return parser.TryParse(quantityString, formatProvider, ElectricResistance.From, out quantity); + + if (quantityType == typeof(ElectricResistivity)) + return parser.TryParse(quantityString, formatProvider, ElectricResistivity.From, out quantity); + + if (quantityType == typeof(Energy)) + return parser.TryParse(quantityString, formatProvider, Energy.From, out quantity); + + if (quantityType == typeof(Entropy)) + return parser.TryParse(quantityString, formatProvider, Entropy.From, out quantity); + + if (quantityType == typeof(Force)) + return parser.TryParse(quantityString, formatProvider, Force.From, out quantity); + + if (quantityType == typeof(ForceChangeRate)) + return parser.TryParse(quantityString, formatProvider, ForceChangeRate.From, out quantity); + + if (quantityType == typeof(ForcePerLength)) + return parser.TryParse(quantityString, formatProvider, ForcePerLength.From, out quantity); + + if (quantityType == typeof(Frequency)) + return parser.TryParse(quantityString, formatProvider, Frequency.From, out quantity); + + if (quantityType == typeof(HeatFlux)) + return parser.TryParse(quantityString, formatProvider, HeatFlux.From, out quantity); + + if (quantityType == typeof(HeatTransferCoefficient)) + return parser.TryParse(quantityString, formatProvider, HeatTransferCoefficient.From, out quantity); + + if (quantityType == typeof(Illuminance)) + return parser.TryParse(quantityString, formatProvider, Illuminance.From, out quantity); + + if (quantityType == typeof(Information)) + return parser.TryParse(quantityString, formatProvider, Information.From, out quantity); + + if (quantityType == typeof(Irradiance)) + return parser.TryParse(quantityString, formatProvider, Irradiance.From, out quantity); + + if (quantityType == typeof(Irradiation)) + return parser.TryParse(quantityString, formatProvider, Irradiation.From, out quantity); + + if (quantityType == typeof(KinematicViscosity)) + return parser.TryParse(quantityString, formatProvider, KinematicViscosity.From, out quantity); + + if (quantityType == typeof(LapseRate)) + return parser.TryParse(quantityString, formatProvider, LapseRate.From, out quantity); + + if (quantityType == typeof(Length)) + return parser.TryParse(quantityString, formatProvider, Length.From, out quantity); + + if (quantityType == typeof(Level)) + return parser.TryParse(quantityString, formatProvider, Level.From, out quantity); + + if (quantityType == typeof(LinearDensity)) + return parser.TryParse(quantityString, formatProvider, LinearDensity.From, out quantity); + + if (quantityType == typeof(LuminousFlux)) + return parser.TryParse(quantityString, formatProvider, LuminousFlux.From, out quantity); + + if (quantityType == typeof(LuminousIntensity)) + return parser.TryParse(quantityString, formatProvider, LuminousIntensity.From, out quantity); + + if (quantityType == typeof(MagneticField)) + return parser.TryParse(quantityString, formatProvider, MagneticField.From, out quantity); + + if (quantityType == typeof(MagneticFlux)) + return parser.TryParse(quantityString, formatProvider, MagneticFlux.From, out quantity); + + if (quantityType == typeof(Magnetization)) + return parser.TryParse(quantityString, formatProvider, Magnetization.From, out quantity); + + if (quantityType == typeof(Mass)) + return parser.TryParse(quantityString, formatProvider, Mass.From, out quantity); + + if (quantityType == typeof(MassFlow)) + return parser.TryParse(quantityString, formatProvider, MassFlow.From, out quantity); + + if (quantityType == typeof(MassFlux)) + return parser.TryParse(quantityString, formatProvider, MassFlux.From, out quantity); + + if (quantityType == typeof(MassMomentOfInertia)) + return parser.TryParse(quantityString, formatProvider, MassMomentOfInertia.From, out quantity); + + if (quantityType == typeof(MolarEnergy)) + return parser.TryParse(quantityString, formatProvider, MolarEnergy.From, out quantity); + + if (quantityType == typeof(MolarEntropy)) + return parser.TryParse(quantityString, formatProvider, MolarEntropy.From, out quantity); + + if (quantityType == typeof(Molarity)) + return parser.TryParse(quantityString, formatProvider, Molarity.From, out quantity); + + if (quantityType == typeof(MolarMass)) + return parser.TryParse(quantityString, formatProvider, MolarMass.From, out quantity); + + if (quantityType == typeof(Permeability)) + return parser.TryParse(quantityString, formatProvider, Permeability.From, out quantity); + + if (quantityType == typeof(Permittivity)) + return parser.TryParse(quantityString, formatProvider, Permittivity.From, out quantity); + + if (quantityType == typeof(Power)) + return parser.TryParse(quantityString, formatProvider, Power.From, out quantity); + + if (quantityType == typeof(PowerDensity)) + return parser.TryParse(quantityString, formatProvider, PowerDensity.From, out quantity); + + if (quantityType == typeof(PowerRatio)) + return parser.TryParse(quantityString, formatProvider, PowerRatio.From, out quantity); + + if (quantityType == typeof(Pressure)) + return parser.TryParse(quantityString, formatProvider, Pressure.From, out quantity); + + if (quantityType == typeof(PressureChangeRate)) + return parser.TryParse(quantityString, formatProvider, PressureChangeRate.From, out quantity); + + if (quantityType == typeof(Ratio)) + return parser.TryParse(quantityString, formatProvider, Ratio.From, out quantity); + + if (quantityType == typeof(ReactiveEnergy)) + return parser.TryParse(quantityString, formatProvider, ReactiveEnergy.From, out quantity); + + if (quantityType == typeof(ReactivePower)) + return parser.TryParse(quantityString, formatProvider, ReactivePower.From, out quantity); + + if (quantityType == typeof(RotationalAcceleration)) + return parser.TryParse(quantityString, formatProvider, RotationalAcceleration.From, out quantity); + + if (quantityType == typeof(RotationalSpeed)) + return parser.TryParse(quantityString, formatProvider, RotationalSpeed.From, out quantity); + + if (quantityType == typeof(RotationalStiffness)) + return parser.TryParse(quantityString, formatProvider, RotationalStiffness.From, out quantity); + + if (quantityType == typeof(RotationalStiffnessPerLength)) + return parser.TryParse(quantityString, formatProvider, RotationalStiffnessPerLength.From, out quantity); + + if (quantityType == typeof(SolidAngle)) + return parser.TryParse(quantityString, formatProvider, SolidAngle.From, out quantity); + + if (quantityType == typeof(SpecificEnergy)) + return parser.TryParse(quantityString, formatProvider, SpecificEnergy.From, out quantity); + + if (quantityType == typeof(SpecificEntropy)) + return parser.TryParse(quantityString, formatProvider, SpecificEntropy.From, out quantity); + + if (quantityType == typeof(SpecificVolume)) + return parser.TryParse(quantityString, formatProvider, SpecificVolume.From, out quantity); + + if (quantityType == typeof(SpecificWeight)) + return parser.TryParse(quantityString, formatProvider, SpecificWeight.From, out quantity); + + if (quantityType == typeof(Speed)) + return parser.TryParse(quantityString, formatProvider, Speed.From, out quantity); + + if (quantityType == typeof(Temperature)) + return parser.TryParse(quantityString, formatProvider, Temperature.From, out quantity); + + if (quantityType == typeof(TemperatureChangeRate)) + return parser.TryParse(quantityString, formatProvider, TemperatureChangeRate.From, out quantity); + + if (quantityType == typeof(TemperatureDelta)) + return parser.TryParse(quantityString, formatProvider, TemperatureDelta.From, out quantity); + + if (quantityType == typeof(ThermalConductivity)) + return parser.TryParse(quantityString, formatProvider, ThermalConductivity.From, out quantity); + + if (quantityType == typeof(ThermalResistance)) + return parser.TryParse(quantityString, formatProvider, ThermalResistance.From, out quantity); + + if (quantityType == typeof(Torque)) + return parser.TryParse(quantityString, formatProvider, Torque.From, out quantity); + + if (quantityType == typeof(VitaminA)) + return parser.TryParse(quantityString, formatProvider, VitaminA.From, out quantity); + + if (quantityType == typeof(Volume)) + return parser.TryParse(quantityString, formatProvider, Volume.From, out quantity); + + if (quantityType == typeof(VolumeFlow)) + return parser.TryParse(quantityString, formatProvider, VolumeFlow.From, out quantity); + + throw new ArgumentException( + $"Type {quantityType} is not a known quantity type. Did you pass in a third-party quantity type defined outside UnitsNet library?"); + } + +#if !WINDOWS_UWP + /// + /// Get information about the given quantity type. + /// + /// The quantity type enum value. + /// Information about the quantity and its units. + public static QuantityInfo GetInfo(QuantityType quantityType) + { + return Infos.First(qi => qi.QuantityType == quantityType); + } +#endif + } +} diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 2b499f4507..dcb6cdf144 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -1,16 +1,16 @@ // Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). // https://github.com/angularsen/UnitsNet -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -21,6 +21,7 @@ using System; using JetBrains.Annotations; +using UnitsNet.Units; namespace UnitsNet { @@ -32,18 +33,50 @@ public partial interface IQuantity /// /// The of this quantity. /// - QuantityType Type - { - get; - } + QuantityType Type { get; } /// /// The of this quantity. /// - BaseDimensions Dimensions - { - get; - } + BaseDimensions Dimensions { get; } + +#if !WINDOWS_UWP + /// + /// Information about the quantity type, such as unit values and names. + /// + QuantityInfo QuantityInfo { get; } +#endif + + /// + /// Dynamically convert to another unit representation. + /// + /// The unit enum value. The unit must be compatible, so for you should provide a value. + /// Value converted to the specified unit. + /// Wrong unit enum type was given. +#if WINDOWS_UWP + double As(object unit); +#else + double As(Enum unit); +#endif + + /// + /// The unit this quantity was constructed with or the BaseUnit if the default constructor was used. + /// + +#if WINDOWS_UWP + object Unit { get; } +#else + Enum Unit { get; } +#endif + +#if !WINDOWS_UWP + /// + /// Change the default unit representation of the quantity, which affects things like . + /// + /// The unit enum value. The unit must be compatible, so for you should provide a value. + /// A new quantity with the given unit as default unit representation. + IQuantity ToUnit(Enum unit); +#endif } #if !WINDOWS_UWP @@ -107,23 +140,26 @@ public partial interface IQuantity #endif #if !WINDOWS_UWP - - public interface IQuantity : IQuantity where UnitType : Enum + public interface IQuantity : IQuantity where TUnitType : Enum { /// - /// Convert to the unit representation . + /// Convert to a unit representation . /// /// Value converted to the specified unit. - double As(UnitType unit); + double As(TUnitType unit); + + /// + new TUnitType Unit { get; } + + /// + new QuantityInfo QuantityInfo { get; } /// - /// The unit this quantity was constructed with or the BaseUnit if the default constructor was used. + /// Change the default unit representation of the quantity, which affects things like . /// - UnitType Unit - { - get; - } + /// + /// + IQuantity ToUnit(TUnitType unit); } - #endif } diff --git a/UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs b/UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs index e57aa2429e..db971f3d00 100644 --- a/UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs +++ b/UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs @@ -19,91 +19,89 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.CompilerServices; using System; using System.Collections.Generic; using System.Reflection; +using System.Runtime.CompilerServices; +#if NET40 || NET35 || NET20 || SILVERLIGHT +using UniformTypeInfo = System.Type; +#else +using UniformTypeInfo = System.Reflection.TypeInfo; +#endif -[assembly: InternalsVisibleTo("UnitsNet.Serialization.JsonNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010089abdcb0025f7d1c4c766686dd852b978ca5bb9fd80bba9d3539e8399b01170ae0ea10c0c3baa301b1d13090d5aff770532de00c88b67c4b24669fde7f9d87218f1c6c073a09016cbb2f87119b94227c2301f4e2a096043e30f7c47c872bbd8e0b80d924952e6b36990f13f847e83e9efb107ec2121fe39d7edaaa4e235af8c4")] +[assembly: + InternalsVisibleTo( + "UnitsNet.Serialization.JsonNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010089abdcb0025f7d1c4c766686dd852b978ca5bb9fd80bba9d3539e8399b01170ae0ea10c0c3baa301b1d13090d5aff770532de00c88b67c4b24669fde7f9d87218f1c6c073a09016cbb2f87119b94227c2301f4e2a096043e30f7c47c872bbd8e0b80d924952e6b36990f13f847e83e9efb107ec2121fe39d7edaaa4e235af8c4")] // Based on // https://github.com/StefH/ReflectionBridge/blob/c1e34e57fe3fc93507e83d5cebc1677396645397/ReflectionBridge/src/ReflectionBridge/Extensions/ReflectionBridgeExtensions.cs // MIT license namespace UnitsNet.InternalHelpers { - internal static class ReflectionBridgeExtensions + internal struct TypeWrapper { - internal static Assembly GetAssembly(this Type type) - { -#if !(NET40 || NET35 || NET20 || SILVERLIGHT) - return type.GetTypeInfo().Assembly; -#else - return type.Assembly; -#endif - } + private readonly Type _type; - internal static bool IsEnum(this Type type) + public TypeWrapper(Type type) { -#if !(NET40 || NET35 || NET20 || SILVERLIGHT) - return type.GetTypeInfo().IsEnum; -#else - return type.IsEnum; -#endif + _type = type; } - internal static bool IsClass(this Type type) + internal Assembly Assembly => _type.ToUniformType().Assembly; + internal bool IsEnum => _type.ToUniformType().IsEnum; + internal bool IsClass => _type.ToUniformType().IsClass; + internal bool IsAssignableFrom(Type other) => _type.ToUniformType().IsAssignableFrom(other.ToUniformType()); + internal bool IsValueType => _type.ToUniformType().IsValueType; + + internal PropertyInfo GetProperty(string name) { -#if !(NET40 || NET35 || NET20 || SILVERLIGHT) - return type.GetTypeInfo().IsClass; +#if NET40 || NET35 || NET20 || SILVERLIGHT + return _type.GetProperty(name); #else - return type.IsClass; + return _type.GetTypeInfo().GetDeclaredProperty(name); #endif } - internal static bool IsValueType(this Type type) + internal IEnumerable GetDeclaredMethods() { -#if !(NET40 || NET35 || NET20 || SILVERLIGHT) - return type.GetTypeInfo().IsValueType; + var t = _type.ToUniformType(); + while (t != null) + { +#if NET40 || NET35 || NET20 || SILVERLIGHT + foreach (MethodInfo m in t.GetMethods()) #else - return type.IsValueType; + foreach (MethodInfo m in t.DeclaredMethods) #endif + yield return m; + + t = t.BaseType?.ToUniformType(); + } } + } - internal static PropertyInfo GetPropety(this Type type, string name) + internal static class ReflectionBridgeExtensions + { + /// + /// Wrap the type to make it .NET agnostic using Type for old targets and the newer TypeInfo for newer targets. + /// + public static TypeWrapper Wrap(this Type type) { -#if (NET40 || NET35 || NET20 || SILVERLIGHT) - return type.GetProperty(name); - -#else - return type.GetTypeInfo().GetDeclaredProperty(name); -#endif + return new TypeWrapper(type); } -#if !(NET40 || NET35 || NET20 || SILVERLIGHT) - // Ambiguous method conflict with GetMethods() name when targeting WindowsRuntimeComponent, so use GetDeclaredMethods() instead - internal static IEnumerable GetDeclaredMethods(this Type someType) + /// + /// Returns the type or type info object depending on compile target, such as TypeInfo for .NET 4.5+ and Type for .NET + /// 4.0 and older. + /// The APIs of these two objects are similar, but obtaining them is slightly different. + /// The idea is to get fewer #if pragma statements in the code. + /// + public static UniformTypeInfo ToUniformType(this Type type) { - Type t = someType; - while (t != null) - { - TypeInfo ti = t.GetTypeInfo(); - foreach (MethodInfo m in ti.DeclaredMethods) - yield return m; - t = ti.BaseType; - } - } +#if NET40 || NET35 || NET20 || SILVERLIGHT + return type; #else -// Ambiguous method conflict with GetMethods() name WindowsRuntimeComponent, so use GetDeclaredMethods() instead - internal static IEnumerable GetDeclaredMethods(this Type someType) - { - Type t = someType; - while (t != null) - { - foreach (MethodInfo m in t.GetMethods()) - yield return m; - t = t.BaseType; - } - } + return type.GetTypeInfo(); #endif + } } } diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs new file mode 100644 index 0000000000..e94db564fb --- /dev/null +++ b/UnitsNet/QuantityInfo.cs @@ -0,0 +1,153 @@ +// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). +// https://github.com/angularsen/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using System.Reflection; +using JetBrains.Annotations; +using UnitsNet.InternalHelpers; +using UnitsNet.Units; + +namespace UnitsNet +{ + /// + /// Information about the quantity, such as names, unit values and zero quantity. + /// This is useful to enumerate units and present names with quantities and units + /// chose dynamically at runtime, such as unit conversion apps or allowing the user to change the + /// unit representation. + /// + /// + /// Typically you obtain this by looking it up via . + /// +#if WINDOWS_UWP + internal +#else + public +#endif + class QuantityInfo + { + private static readonly string UnitEnumNamespace = typeof(LengthUnit).Namespace; + + private static readonly Type[] UnitEnumTypes = typeof(Length) + .Wrap() + .Assembly + .GetExportedTypes() + .Where(t => t.Wrap().IsEnum && t.Namespace == UnitEnumNamespace && t.Name.EndsWith("Unit")) + .ToArray(); + + public QuantityInfo(QuantityType quantityType, [NotNull] Enum[] units, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions) + { + if(quantityType == QuantityType.Undefined) throw new ArgumentException("Quantity type can not be undefined.", nameof(quantityType)); + if(units == null) throw new ArgumentNullException(nameof(units)); + if(baseUnit == null) throw new ArgumentNullException(nameof(baseUnit)); + if(zero == null) throw new ArgumentNullException(nameof(zero)); + if(baseDimensions == null) throw new ArgumentNullException(nameof(baseDimensions)); + + Name = quantityType.ToString(); + QuantityType = quantityType; + UnitType = UnitEnumTypes.First(t => t.Name == $"{quantityType}Unit"); + UnitNames = units.Select(u => u.ToString()).ToArray(); + Units = units; + BaseUnit = baseUnit; + Zero = zero; + ValueType = zero.GetType(); + BaseDimensions = baseDimensions; + } + + /// + /// Quantity name, such as "Length" or "Mass". + /// + public string Name { get; } + + /// + /// Quantity type, such as or . + /// + public QuantityType QuantityType { get; } + + /// + /// All unit names for the quantity, such as ["Centimeter", "Decimeter", "Meter", ...]. + /// + public string[] UnitNames { get; } + + /// + /// All unit enum values for the quantity, such as [, + /// , , ...]. + /// + public Enum[] Units { get; } + + /// + /// The base unit for the quantity, such as . + /// + public Enum BaseUnit { get; } + + /// + /// Zero value of quantity, such as . + /// + public IQuantity Zero { get; } + + /// + /// Unit enum type, such as or . + /// + public Type UnitType { get; } + + /// + /// Quantity value type, such as or . + /// + public Type ValueType { get; } + + /// + /// The for a quantity. + /// + public BaseDimensions BaseDimensions { get; } + } + +#if !WINDOWS_UWP + /// + /// + /// This is a specialization of , for when the unit type is known. + /// Typically you obtain this by looking it up statically from or + /// , or dynamically via . + /// + /// The unit enum type, such as . + public class QuantityInfo : QuantityInfo + where TUnit : Enum + { + public QuantityInfo(QuantityType quantityType, TUnit[] units, TUnit baseUnit, IQuantity zero, BaseDimensions baseDimensions) + : base(quantityType, units.Cast().ToArray(), baseUnit, zero, baseDimensions) + { + Zero = zero; + Units = units; + BaseUnit = baseUnit; + } + + /// + public new TUnit[] Units { get; } + + public new TUnit BaseUnit { get; } + + /// + public new IQuantity Zero { get; } + + /// + public new TUnit UnitType { get; } + } +#endif +} diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index 2838e37c50..e1385fa68e 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -103,6 +103,11 @@ public static explicit operator decimal(QuantityValue number) } #endregion + + public override string ToString() + { + return _value.HasValue ? _value.ToString() : _valueDecimal.ToString(); + } } } #endif diff --git a/UnitsNet/Scripts/GenerateUnits.ps1 b/UnitsNet/Scripts/GenerateUnits.ps1 index 1b305d79a5..56191e7025 100644 --- a/UnitsNet/Scripts/GenerateUnits.ps1 +++ b/UnitsNet/Scripts/GenerateUnits.ps1 @@ -19,12 +19,12 @@ function ValueOrDefault($value, $defaultValue){ function GenerateQuantity([Quantity]$quantity, $outDir) { $outFileName = "$outDir/$($quantity.Name).NetFramework.g.cs" - GenerateQuantitySourceCodeNetFramework $quantity "NetFramework" | Out-File -Encoding "UTF8" $outFileName | Out-Null + GenerateQuantitySourceCode $quantity "NetFramework" | Out-File -Encoding "UTF8" $outFileName | Out-Null if (!$?) { exit 1 } Write-Host -NoNewline "quantity .NET(OK) " $outFileName = "$outDir/../../../UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/$($quantity.Name).WindowsRuntimeComponent.g.cs" - GenerateQuantitySourceCodeNetFramework $quantity "WindowsRuntimeComponent" | Out-File -Encoding "UTF8" $outFileName | Out-Null + GenerateQuantitySourceCode $quantity "WindowsRuntimeComponent" | Out-File -Encoding "UTF8" $outFileName | Out-Null if (!$?) { exit 1 } Write-Host -NoNewline "quantity WRC(OK) " } @@ -95,6 +95,19 @@ function GenerateQuantityType($quantities, $outDir) Write-Host "(OK) " } +function GenerateStaticQuantity($quantities, $outDir) +{ + Write-Host -NoNewline "Quantity.g.cs: " + $outFileName = "$outDir/Quantity.g.cs" + + GenerateStaticQuantitySourceCode $quantities | Out-File -Encoding "UTF8" -Force $outFileName | Out-Null + if (!$?) { + Write-Host "(error) " + exit 1 + } + Write-Host "(OK) " +} + function EnsureDirExists([String] $dirPath) { New-Item -ItemType Directory -Force -Path $dirPath | Out-Null if (!$?) { @@ -229,7 +242,8 @@ function Add-InheritedUnits([Quantity]$quantity, $quantities) { . "$PSScriptRoot/Include-GenerateTemplates.ps1" . "$PSScriptRoot/Include-GenerateUnitSystemDefaultSourceCode.ps1" . "$PSScriptRoot/Include-GenerateQuantityTypeSourceCode.ps1" -. "$PSScriptRoot/Include-GenerateQuantitySourceCodeNetFramework.ps1" +. "$PSScriptRoot/Include-GenerateStaticQuantitySourceCode.ps1" +. "$PSScriptRoot/Include-GenerateQuantitySourceCode.ps1" . "$PSScriptRoot/Include-GenerateUnitTypeSourceCode.ps1" . "$PSScriptRoot/Include-GenerateUnitTestBaseClassSourceCode.ps1" . "$PSScriptRoot/Include-GenerateUnitTestPlaceholderSourceCode.ps1" @@ -311,6 +325,7 @@ foreach ($quantity in $quantities) { Write-Host "" GenerateUnitSystemDefault $quantities $unitSystemDir GenerateQuantityType $quantities $unitSystemDir +GenerateStaticQuantity $quantities $unitSystemDir $unitCount = ($quantities | %{$_.Units.Count} | Measure -Sum).Sum diff --git a/UnitsNet/Scripts/Include-GenerateQuantitySourceCodeNetFramework.ps1 b/UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1 similarity index 96% rename from UnitsNet/Scripts/Include-GenerateQuantitySourceCodeNetFramework.ps1 rename to UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1 index d725bd7293..b609ed7fd6 100644 --- a/UnitsNet/Scripts/Include-GenerateQuantitySourceCodeNetFramework.ps1 +++ b/UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1 @@ -8,7 +8,7 @@ class GeneratorArgs [boolean]$TargetIsWindowsRuntimeComponent } -function GenerateQuantitySourceCodeNetFramework([Quantity]$quantity, [string]$target) +function GenerateQuantitySourceCode([Quantity]$quantity, [string]$target) { $quantityName = $quantity.Name; $units = $quantity.Units; @@ -19,6 +19,8 @@ function GenerateQuantitySourceCodeNetFramework([Quantity]$quantity, [string]$ta $unitEnumName = "$quantityName" + "Unit" $wrc = $target -eq "WindowsRuntimeComponent" $privateAccessModifierIfWrc = if ($wrc) { "private" } else { "public" } + $accessModifier = if ($wrc) { "internal" } else { "public" } + $enumOrObject = if ($wrc) { "object" } else { "Enum" } $baseDimensions = $quantity.BaseDimensions; $isDimensionless = $baseDimensions -eq $null -or ( $baseDimensions.Length -eq 0 -and $baseDimensions.Mass -eq 0 -and $baseDimensions.Time -eq 0 -and $baseDimensions.ElectricCurrent -eq 0 -and $baseDimensions.Temperature -eq 0 -and $baseDimensions.AmountOfSubstance -eq 0 -and $baseDimensions.LuminousIntensity -eq 0 ) @@ -122,7 +124,11 @@ if ($obsoleteAttribute) {@" BaseDimensions = new BaseDimensions($($baseDimensions.Length), $($baseDimensions.Mass), $($baseDimensions.Time), $($baseDimensions.ElectricCurrent), $($baseDimensions.Temperature), $($baseDimensions.AmountOfSubstance), $($baseDimensions.LuminousIntensity)); "@; } -@" + if ($wrc) {@" + Info = new QuantityInfo(QuantityType.$quantityName, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); +"@; } else {@" + Info = new QuantityInfo<$unitEnumName>(QuantityType.$quantityName, Units, BaseUnit, Zero, BaseDimensions); +"@; }@" } "@; # Windows Runtime Component requires a default constructor if ($wrc) {@" @@ -271,6 +277,13 @@ function GenerateStaticProperties([GeneratorArgs]$genArgs) #region Static Properties + /// +"@; if ($wrc) {@" + internal static QuantityInfo Info { get; } +"@; } else {@" + public static QuantityInfo<$unitEnumName> Info { get; } +"@; }@" + /// /// The of this quantity. /// @@ -325,18 +338,30 @@ function GenerateProperties([GeneratorArgs]$genArgs) /// The numeric value this quantity was constructed with. /// "@; # Windows Runtime Component does not support decimal - if ($wrc) {@" + if ($wrc) {@" public double Value => Convert.ToDouble(_value); "@; } else {@" public $valueType Value => _value; "@; } @" + /// + $enumOrObject IQuantity.Unit => Unit; + /// /// The unit this quantity was constructed with -or- if default ctor was used. /// public $unitEnumName Unit => _unit.GetValueOrDefault(BaseUnit); +"@; if ($wrc) {@" + internal QuantityInfo QuantityInfo => Info; +"@; } else {@" + public QuantityInfo<$unitEnumName> QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; +"@; }@" + /// /// The of this quantity. /// @@ -812,12 +837,12 @@ function GenerateEqualityAndComparison([GeneratorArgs]$genArgs) return left.Value > right.AsBaseNumericType(left.Unit); } - public static bool operator ==($quantityName left, $quantityName right) + public static bool operator ==($quantityName left, $quantityName right) { return left.Equals(right); } - public static bool operator !=($quantityName left, $quantityName right) + public static bool operator !=($quantityName left, $quantityName right) { return !(left == right); } @@ -831,8 +856,6 @@ function GenerateEqualityAndComparison([GeneratorArgs]$genArgs) return CompareTo(obj$quantityName); } -"@; # Windows Runtime Component does not support overloads with same number of parameters -$accessModifier = if ($wrc) { "internal" } else { "public" } @" // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods $accessModifier int CompareTo($quantityName other) { @@ -929,6 +952,8 @@ function GenerateConversionMethods([GeneratorArgs]$genArgs) #region Conversion Methods + double IQuantity.As($enumOrObject unit) => As(($unitEnumName)unit); + /// /// Convert to the unit representation . /// @@ -942,6 +967,10 @@ function GenerateConversionMethods([GeneratorArgs]$genArgs) return Convert.ToDouble(converted); } +"@; if (-not $wrc) {@" + public double As(Enum unit) => As(($unitEnumName) unit); + +"@; }@" /// /// Converts this $quantityName to another $quantityName with the unit representation . /// @@ -952,6 +981,12 @@ function GenerateConversionMethods([GeneratorArgs]$genArgs) return new $quantityName(convertedValue, unit); } +"@; if (-not $wrc) {@" + IQuantity<$unitEnumName> IQuantity<$unitEnumName>.ToUnit($unitEnumName unit) => ToUnit(unit); + + public IQuantity ToUnit(Enum unit) => ToUnit(($unitEnumName) unit); + +"@; }@" /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet/Scripts/Include-GenerateQuantityTypeSourceCode.ps1 b/UnitsNet/Scripts/Include-GenerateQuantityTypeSourceCode.ps1 index a480e56f37..11b0c4933e 100644 --- a/UnitsNet/Scripts/Include-GenerateQuantityTypeSourceCode.ps1 +++ b/UnitsNet/Scripts/Include-GenerateQuantityTypeSourceCode.ps1 @@ -1,4 +1,4 @@ -function GenerateQuantityTypeSourceCode($quantityNames) +function GenerateQuantityTypeSourceCode($quantities) { @" //------------------------------------------------------------------------------ @@ -51,9 +51,9 @@ namespace UnitsNet public enum QuantityType { Undefined = 0, -"@; foreach ($quantityName in $quantityNames) { +"@; foreach ($quantity in $quantities) { @" - $($quantityName.Name), + $($quantity.Name), "@; }@" } } diff --git a/UnitsNet/Scripts/Include-GenerateStaticQuantitySourceCode.ps1 b/UnitsNet/Scripts/Include-GenerateStaticQuantitySourceCode.ps1 new file mode 100644 index 0000000000..0539c41fd0 --- /dev/null +++ b/UnitsNet/Scripts/Include-GenerateStaticQuantitySourceCode.ps1 @@ -0,0 +1,205 @@ +using module ".\Types.psm1" + +function GenerateStaticQuantitySourceCode([Quantity[]]$quantities, [string]$target) +{ +@" +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). +// https://github.com/angularsen/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using JetBrains.Annotations; +using UnitsNet.InternalHelpers; +using UnitsNet.Units; + +#if WINDOWS_UWP +using FromValue = System.Double; +#else +using FromValue = UnitsNet.QuantityValue; +#endif + +namespace UnitsNet +{ + /// + /// Dynamically parse or construct quantities when types are only known at runtime. + /// +#if WINDOWS_UWP + internal +#else + public +#endif + static partial class Quantity + { +#if !WINDOWS_UWP + /// + public static bool TryFrom(double value, Enum unit, out IQuantity quantity) + { + // Implicit cast to FromValue would prevent TryFrom from being called, + // so we need to explicitly check this here for double arguments. + if (double.IsNaN(value) || double.IsInfinity(value)) + { + quantity = default(IQuantity); + return false; + } + + return TryFrom((FromValue) value, unit, out quantity); + } +#endif + + /// + /// Try to dynamically construct a quantity. + /// + /// Numeric value. + /// Unit enum value. + /// The resulting quantity if successful, otherwise default. + /// True if successful with assigned the value, otherwise false. +#if WINDOWS_UWP + internal +#else + public +#endif + static bool TryFrom(FromValue value, Enum unit, out IQuantity quantity) + { + switch (unit) + { +"@; foreach ($quantity in $quantities) { + $quantityName = $quantity.Name + $unitTypeName = $quantityName + "Unit" + $unitValue = toCamelCase($unitTypeName);@" + case $unitTypeName $($unitValue): + quantity = $quantityName.From(value, $unitValue); + return true; +"@; }@" + default: + { + quantity = default(IQuantity); + return false; + } + } + } + + /// +#if WINDOWS_UWP + internal +#else + public +#endif + static IQuantity Parse(Type quantityType, string quantityString) => Parse(null, quantityType, quantityString); + + /// + /// Dynamically parse a quantity string representation. + /// + /// The format provider to use for lookup. Defaults to if null. + /// Type of quantity, such as . + /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. + /// The parsed quantity. + /// Type must be of type UnitsNet.IQuantity -or- Type is not a known quantity type. +#if WINDOWS_UWP + internal +#else + public +#endif + static IQuantity Parse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString) + { + if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + throw new ArgumentException($"Type {quantityType} must be of type UnitsNet.IQuantity."); + + if (TryParse(formatProvider, quantityType, quantityString, out IQuantity quantity)) return quantity; + + throw new ArgumentException($"Quantity string could not be parsed to quantity {quantityType}."); + } + + /// +#if WINDOWS_UWP + internal +#else + public +#endif + static bool TryParse(Type quantityType, string quantityString, out IQuantity quantity) => + TryParse(null, quantityType, quantityString, out quantity); + + /// + /// Try to dynamically parse a quantity string representation. + /// + /// The format provider to use for lookup. Defaults to if null. + /// Type of quantity, such as . + /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. + /// The resulting quantity if successful, otherwise default. + /// The parsed quantity. +#if WINDOWS_UWP + internal +#else + public +#endif + static bool TryParse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString, out IQuantity quantity) + { + quantity = default(IQuantity); + + if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + return false; + + var parser = QuantityParser.Default; + +"@; foreach ($quantity in $quantities) { + $quantityName = $quantity.Name;@" + if (quantityType == typeof($quantityName)) + return parser.TryParse<$quantityName, $($quantityName)Unit>(quantityString, formatProvider, $quantityName.From, out quantity); + +"@; }@" + throw new ArgumentException( + $"Type {quantityType} is not a known quantity type. Did you pass in a third-party quantity type defined outside UnitsNet library?"); + } + +#if !WINDOWS_UWP + /// + /// Get information about the given quantity type. + /// + /// The quantity type enum value. + /// Information about the quantity and its units. + public static QuantityInfo GetInfo(QuantityType quantityType) + { + return Infos.First(qi => qi.QuantityType == quantityType); + } +#endif + } +} +"@; +} + +function toCamelCase([string] $str) { + return [char]::ToLower($str[0]) + $str.Substring(1) +} diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 6b83b9a630..16c006db11 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -25,6 +25,7 @@ using System.Reflection; using UnitsNet.InternalHelpers; using UnitsNet.Units; + #if WINDOWS_UWP using Culture = System.String; using FromValue = System.Double; @@ -41,17 +42,48 @@ namespace UnitsNet public static class UnitConverter { private static readonly string UnitTypeNamespace = typeof(LengthUnit).Namespace; - private static readonly Assembly UnitsNetAssembly = typeof(Length).GetAssembly(); + private static readonly Assembly UnitsNetAssembly = typeof(Length).Wrap().Assembly; private static readonly Type[] QuantityTypes = UnitsNetAssembly.GetTypes() - .Where(typeof(IQuantity).IsAssignableFrom) - .Where(x => x.IsClass() || x.IsValueType()) // Future-proofing: we are discussing changing quantities from struct to class + .Where(typeof(IQuantity).Wrap().IsAssignableFrom) + .Where(x => x.Wrap().IsClass || x.Wrap().IsValueType) // Future-proofing: we are discussing changing quantities from struct to class .ToArray(); private static readonly Type[] UnitTypes = UnitsNetAssembly.GetTypes() - .Where(x => x.Namespace == UnitTypeNamespace && x.IsEnum() && x.Name.EndsWith("Unit")) + .Where(x => x.Namespace == UnitTypeNamespace && x.Wrap().IsEnum && x.Name.EndsWith("Unit")) .ToArray(); + /// + /// Convert between any two quantity units given a numeric value and two unit enum values. + /// + /// Numeric value. + /// From unit enum value. + /// To unit enum value, must be compatible with . + /// The converted value in the new unit representation. + internal static double Convert(FromValue fromValue, Enum fromUnitValue, Enum toUnitValue) + { + return Quantity + .From(fromValue, fromUnitValue) + .As(toUnitValue); + } + + internal static bool TryConvert(FromValue fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue) + { + convertedValue = 0; + if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity from)) return false; + + try + { + // We're not going to implement TryAs() in all quantities, so let's just try-catch here + convertedValue = from.As(toUnitValue); + return true; + } + catch + { + return false; + } + } + /// /// Convert between any two quantity units by their names, such as converting a "Length" of N "Meter" to "Centimeter". /// This is particularly useful for creating things like a generated unit conversion UI, @@ -83,33 +115,24 @@ public static class UnitConverter /// More than one unit matches the abbreviation. public static double ConvertByName(FromValue fromValue, string quantityName, string fromUnit, string toUnit) { - if(!TryGetQuantityType(quantityName, out var quantityType)) - throw new QuantityNotFoundException($"The given quantity name was not found: {quantityName}"); - - if(!TryGetUnitType(quantityName, out var unitType)) + if (!TryGetUnitType(quantityName, out Type unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); - if(!TryParseUnit(unitType, fromUnit, out var fromUnitValue)) // ex: LengthUnit.Meter + if (!TryParseUnit(unitType, fromUnit, out Enum fromUnitValue)) // ex: LengthUnit.Meter { var e = new UnitNotFoundException($"Unit not found [{fromUnit}]."); e.Data["unitName"] = fromUnit; throw e; } - if(!TryParseUnit(unitType, toUnit, out var toUnitValue)) // ex: LengthUnit.Centimeter + if (!TryParseUnit(unitType, toUnit, out Enum toUnitValue)) // ex: LengthUnit.Centimeter { var e = new UnitNotFoundException($"Unit not found [{toUnit}]."); e.Data["unitName"] = toUnit; throw e; } - var fromMethod = GetStaticFromMethod(quantityType, unitType); // ex: UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) - var fromResult = fromMethod.Invoke(null, new[] {fromValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) - - var asMethod = GetAsMethod(quantityType, unitType); // ex: quantity.As(LengthUnit outputUnit) - var asResult = asMethod.Invoke(fromResult, new[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) - - return (double)asResult; + return Convert(fromValue, fromUnitValue, toUnitValue); } /// @@ -143,25 +166,16 @@ public static bool TryConvertByName(FromValue inputValue, string quantityName, s { result = 0d; - if(!TryGetQuantityType(quantityName, out var quantityType)) + if (!TryGetUnitType(quantityName, out var unitType)) return false; - if(!TryGetUnitType(quantityName, out var unitType)) + if (!TryParseUnit(unitType, fromUnit, out var fromUnitValue)) // ex: LengthUnit.Meter return false; - if(!TryParseUnit(unitType, fromUnit, out var fromUnitValue)) // ex: LengthUnit.Meter + if (!TryParseUnit(unitType, toUnit, out var toUnitValue)) // ex: LengthUnit.Centimeter return false; - if(!TryParseUnit(unitType, toUnit, out var toUnitValue)) // ex: LengthUnit.Centimeter - return false; - - var fromMethod = GetStaticFromMethod(quantityType, unitType); // ex: UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) - var fromResult = fromMethod.Invoke(null, new[] {inputValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) - - var asMethod = GetAsMethod(quantityType, unitType); // ex: quantity.As(LengthUnit outputUnit) - var asResult = asMethod.Invoke(fromResult, new[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) - - result = (double)asResult; + result = Convert(inputValue, fromUnitValue, toUnitValue); return true; } @@ -225,29 +239,32 @@ public static double ConvertByAbbreviation(FromValue fromValue, string quantityN /// Culture to parse abbreviations with. /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// Output value as the result of converting to . - /// No quantity types match the . - /// No unit types match the prefix of or no units are mapped to the abbreviation. + /// No quantity types match the . + /// + /// No unit types match the prefix of or no units + /// are mapped to the abbreviation. + /// /// More than one unit matches the abbreviation. public static double ConvertByAbbreviation(FromValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string culture) { - if(!TryGetQuantityType(quantityName, out var quantityType)) + if (!TryGetQuantityType(quantityName, out var quantityType)) throw new QuantityNotFoundException($"The given quantity name was not found: {quantityName}"); - if(!TryGetUnitType(quantityName, out var unitType)) + if (!TryGetUnitType(quantityName, out var unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); - var cultureInfo = string.IsNullOrWhiteSpace(culture)? GlobalConfiguration.DefaultCulture : new CultureInfo(culture); + var cultureInfo = string.IsNullOrWhiteSpace(culture) ? GlobalConfiguration.DefaultCulture : new CultureInfo(culture); var fromUnitValue = UnitParser.Default.Parse(fromUnitAbbrev, unitType, cultureInfo); // ex: ("m", LengthUnit) => LengthUnit.Meter var toUnitValue = UnitParser.Default.Parse(toUnitAbbrev, unitType, cultureInfo); // ex:("cm", LengthUnit) => LengthUnit.Centimeter var fromMethod = GetStaticFromMethod(quantityType, unitType); // ex: UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) - var fromResult = fromMethod.Invoke(null, new[] {fromValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) + var fromResult = fromMethod.Invoke(null, new object[] {fromValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) var asMethod = GetAsMethod(quantityType, unitType); // ex: quantity.As(LengthUnit outputUnit) - var asResult = asMethod.Invoke(fromResult, new[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) + var asResult = asMethod.Invoke(fromResult, new object[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) - return (double)asResult; + return (double) asResult; } /// @@ -315,27 +332,27 @@ public static bool TryConvertByAbbreviation(FromValue fromValue, string quantity { result = 0d; - if(!TryGetQuantityType(quantityName, out var quantityType)) + if (!TryGetQuantityType(quantityName, out var quantityType)) return false; - if(!TryGetUnitType(quantityName, out var unitType)) + if (!TryGetUnitType(quantityName, out var unitType)) return false; - var cultureInfo = string.IsNullOrWhiteSpace(culture)? GlobalConfiguration.DefaultCulture : new CultureInfo(culture); + var cultureInfo = string.IsNullOrWhiteSpace(culture) ? GlobalConfiguration.DefaultCulture : new CultureInfo(culture); - if(!UnitParser.Default.TryParse(fromUnitAbbrev, unitType, cultureInfo, out var fromUnitValue)) // ex: ("m", LengthUnit) => LengthUnit.Meter + if (!UnitParser.Default.TryParse(fromUnitAbbrev, unitType, cultureInfo, out var fromUnitValue)) // ex: ("m", LengthUnit) => LengthUnit.Meter return false; - if(!UnitParser.Default.TryParse(toUnitAbbrev, unitType, cultureInfo, out var toUnitValue)) // ex:("cm", LengthUnit) => LengthUnit.Centimeter + if (!UnitParser.Default.TryParse(toUnitAbbrev, unitType, cultureInfo, out var toUnitValue)) // ex:("cm", LengthUnit) => LengthUnit.Centimeter return false; var fromMethod = GetStaticFromMethod(quantityType, unitType); // ex: UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) - var fromResult = fromMethod.Invoke(null, new[] {fromValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) + var fromResult = fromMethod.Invoke(null, new object[] {fromValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) var asMethod = GetAsMethod(quantityType, unitType); // ex: quantity.As(LengthUnit outputUnit) - var asResult = asMethod.Invoke(fromResult, new[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) + var asResult = asMethod.Invoke(fromResult, new object[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) - result = (double)asResult; + result = (double) asResult; return true; } @@ -343,7 +360,7 @@ private static MethodInfo GetAsMethod(Type quantityType, Type unitType) { // Only a single As() method as of this writing, but let's safe-guard a bit for future-proofing // ex: double result = quantity.As(LengthUnit outputUnit); - return quantityType.GetDeclaredMethods() + return quantityType.Wrap().GetDeclaredMethods() .Single(m => m.Name == "As" && !m.IsStatic && m.IsPublic && @@ -355,7 +372,7 @@ private static MethodInfo GetStaticFromMethod(Type quantityType, Type unitType) { // Want to match: Length l = UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) // Do NOT match : Length? UnitsNet.Length.From(double? inputValue, LengthUnit inputUnit) - return quantityType.GetDeclaredMethods() + return quantityType.Wrap().GetDeclaredMethods() .Single(m => m.Name == "From" && m.IsStatic && m.IsPublic && @@ -389,15 +406,15 @@ private static bool HasParameterTypes(MethodInfo methodInfo, params Type[] expec /// The return enum value, such as boxed as an object. /// True if succeeded, otherwise false. /// No unit values match the . - private static bool TryParseUnit(Type unitType, string unitName, out object unitValue) + private static bool TryParseUnit(Type unitType, string unitName, out Enum unitValue) { unitValue = null; var eNames = Enum.GetNames(unitType); unitName = eNames.FirstOrDefault(x => x.Equals(unitName, StringComparison.OrdinalIgnoreCase)); - if(unitName == null) + if (unitName == null) return false; - unitValue = Enum.Parse(unitType, unitName); + unitValue = (Enum) Enum.Parse(unitType, unitName); return true; } diff --git a/UnitsNet/UnitsNet.csproj.DotSettings b/UnitsNet/UnitsNet.csproj.DotSettings new file mode 100644 index 0000000000..0b0edaecd0 --- /dev/null +++ b/UnitsNet/UnitsNet.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file