2023-02-26 09:38:28 +00:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Units;
|
|
|
|
|
|
|
|
public static class Units
|
|
|
|
{
|
2023-03-02 16:15:10 +00:00
|
|
|
static Units()
|
|
|
|
{
|
|
|
|
JsonConverters = typeof(Units)
|
|
|
|
.Assembly
|
|
|
|
.GetTypes()
|
|
|
|
.Where(t => t.IsAssignableTo(typeof(JsonConverter)))
|
|
|
|
.Select(Activator.CreateInstance)
|
|
|
|
.Cast<JsonConverter>()
|
|
|
|
.ToArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static IReadOnlyList<JsonConverter> JsonConverters { get; }
|
|
|
|
|
|
|
|
public static Byte DisplaySignificantDigits { get; set; } = 3;
|
|
|
|
public static Byte JsonSignificantDigits { get; set; } = 3;
|
|
|
|
|
2023-03-20 12:22:57 +00:00
|
|
|
public static Current A (this Decimal value) => value;
|
|
|
|
public static Voltage V (this Decimal value) => value;
|
|
|
|
public static Power W (this Decimal value) => value;
|
|
|
|
public static ReactivePower Var (this Decimal value) => value;
|
|
|
|
public static ApparentPower Va (this Decimal value) => value;
|
|
|
|
public static Resistance Ohm (this Decimal value) => value;
|
|
|
|
public static Frequency Hz (this Decimal value) => value;
|
|
|
|
public static Angle Rad (this Decimal value) => value;
|
|
|
|
public static Temperature Celsius(this Decimal value) => value;
|
|
|
|
public static Energy KWh (this Decimal value) => value;
|
2023-02-26 09:38:28 +00:00
|
|
|
}
|