26.06.08
This commit is contained in:
@@ -142,7 +142,6 @@ namespace QWERTYkez.Mensura
|
|||||||
// Например:
|
// Например:
|
||||||
string template = @"
|
string template = @"
|
||||||
global using {typeNameZ}Extensions = QWERTYkez.Mensura.Units.{typeNameZ}Extensions;
|
global using {typeNameZ}Extensions = QWERTYkez.Mensura.Units.{typeNameZ}Extensions;
|
||||||
global using {typeNameZ}Converter = QWERTYkez.Mensura.Units.{typeNameZ}Converter;
|
|
||||||
global using {typeNameZ} = QWERTYkez.Mensura.Units.{typeNameZ};
|
global using {typeNameZ} = QWERTYkez.Mensura.Units.{typeNameZ};
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -150,250 +149,7 @@ using System.Runtime.Serialization;
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura.Units;
|
namespace QWERTYkez.Mensura.Units;
|
||||||
|
|
||||||
public readonly partial record struct {typeNameB}
|
[Newtonsoft.Json.JsonConverter(typeof(NewtonsoftUnitConverter<{typeNameZ}>)), JsonConverter(typeof(UnitJsonConverter<{typeNameZ}>))]
|
||||||
{
|
|
||||||
public static {typeNameZ} operator /({typeNameA} left, {typeNameB} right) => new(left._Value / right._Value);
|
|
||||||
public static {typeNameZ} operator /({typeNameA}? left, {typeNameB} right) => new(left.Protected() / right._Value);
|
|
||||||
public static {typeNameZ} operator /({typeNameA} left, {typeNameB}? right) => new(left._Value / right.Protected());
|
|
||||||
public static {typeNameZ} operator /({typeNameA}? left, {typeNameB}? right) => new(left.Protected() / right.Protected());
|
|
||||||
|
|
||||||
|
|
||||||
// === Array ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
|
||||||
*({typeNameZ}[] units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
|
||||||
*({typeNameZ}?[] units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
|
||||||
*({typeNameB} multiplicator, {typeNameZ}[] units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
|
||||||
*({typeNameB} multiplicator, {typeNameZ}?[] units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameZ}[] units, {typeNameB}? multiplicator) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameZ}?[] units, {typeNameB}? multiplicator) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}?[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameB}? multiplicator, {typeNameZ}[] units) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameB}? multiplicator, {typeNameZ}?[] units) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}?[units.Length]);
|
|
||||||
|
|
||||||
// === List<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
|
||||||
*(List<{typeNameZ}> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
|
||||||
*(List<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
|
||||||
*({typeNameB} multiplicator, List<{typeNameZ}> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
|
||||||
*({typeNameB} multiplicator, List<{typeNameZ}?> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *(List<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *(List<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}?>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *({typeNameB}? multiplicator, List<{typeNameZ}> units) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *({typeNameB}? multiplicator, List<{typeNameZ}?> units) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}?>(units.Count));
|
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
|
||||||
*(IEnumerable<{typeNameZ}> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
|
||||||
*(IEnumerable<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
|
||||||
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
|
||||||
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}?> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *(IEnumerable<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *(IEnumerable<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameA}?)null : new {typeNameA}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *({typeNameB}? multiplicator, IEnumerable<{typeNameZ}> units) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *({typeNameB}? multiplicator, IEnumerable<{typeNameZ}?> units) =>
|
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameA}?)null : new {typeNameA}(0d)));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// === Array ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
|
||||||
/({typeNameA}[] units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
|
||||||
/({typeNameA}?[] units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
|
||||||
/({typeNameB} dividend, {typeNameA}[] units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
|
||||||
/({typeNameB} dividend, {typeNameA}?[] units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameA}[] units, {typeNameB}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameA}?[] units, {typeNameB}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameB}? dividend, {typeNameA}[] units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameB}? dividend, {typeNameA}?[] units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
|
||||||
|
|
||||||
// === List<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
|
||||||
/(List<{typeNameA}> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
|
||||||
/(List<{typeNameA}?> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
|
||||||
/({typeNameB} dividend, List<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
|
||||||
/({typeNameB} dividend, List<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameA}> units, {typeNameB}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameA}?> units, {typeNameB}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /({typeNameB}? dividend, List<{typeNameA}> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /({typeNameB}? dividend, List<{typeNameA}?> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
|
||||||
/(IEnumerable<{typeNameA}> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
|
||||||
/(IEnumerable<{typeNameA}?> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
|
||||||
/({typeNameB} dividend, IEnumerable<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
|
||||||
/({typeNameB} dividend, IEnumerable<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameA}> units, {typeNameB}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameA}?> units, {typeNameB}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /({typeNameB}? dividend, IEnumerable<{typeNameA}> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /({typeNameB}? dividend, IEnumerable<{typeNameA}?> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
|
||||||
}
|
|
||||||
public readonly partial record struct {typeNameA}
|
|
||||||
{
|
|
||||||
// === Array ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
|
||||||
/({typeNameZ}[] units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
|
||||||
/({typeNameZ}?[] units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
|
||||||
/({typeNameA} dividend, {typeNameZ}[] units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
|
||||||
/({typeNameA} dividend, {typeNameZ}?[] units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameZ}[] units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameZ}?[] units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}?[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameA}? dividend, {typeNameZ}[] units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameA}? dividend, {typeNameZ}?[] units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameB}?[units.Length]);
|
|
||||||
|
|
||||||
// === List<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
|
||||||
/(List<{typeNameZ}> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
|
||||||
/(List<{typeNameZ}?> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
|
||||||
/({typeNameA} dividend, List<{typeNameZ}> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
|
||||||
/({typeNameA} dividend, List<{typeNameZ}?> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /(List<{typeNameZ}> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /(List<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}?>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /({typeNameA}? dividend, List<{typeNameZ}> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /({typeNameA}? dividend, List<{typeNameZ}?> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameB}?>(units.Count));
|
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
|
||||||
/(IEnumerable<{typeNameZ}> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
|
||||||
/(IEnumerable<{typeNameZ}?> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameZ}> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameZ}?> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /(IEnumerable<{typeNameZ}> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /(IEnumerable<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameB}?)null : new {typeNameB}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /({typeNameA}? dividend, IEnumerable<{typeNameZ}> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /({typeNameA}? dividend, IEnumerable<{typeNameZ}?> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameB}?)null : new {typeNameB}(0d)));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// === Array ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
|
||||||
/({typeNameB}[] units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
|
||||||
/({typeNameB}?[] units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
|
||||||
/({typeNameA} dividend, {typeNameB}[] units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
|
||||||
/({typeNameA} dividend, {typeNameB}?[] units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameB}[] units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameB}?[] units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameA}? dividend, {typeNameB}[] units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameA}? dividend, {typeNameB}?[] units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
|
||||||
|
|
||||||
// === List<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
|
||||||
/(List<{typeNameB}> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
|
||||||
/(List<{typeNameB}?> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
|
||||||
/({typeNameA} dividend, List<{typeNameB}> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
|
||||||
/({typeNameA} dividend, List<{typeNameB}?> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameB}> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameB}?> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /({typeNameA}? dividend, List<{typeNameB}> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /({typeNameA}? dividend, List<{typeNameB}?> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
|
||||||
/(IEnumerable<{typeNameB}> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
|
||||||
/(IEnumerable<{typeNameB}?> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameB}> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameB}?> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameB}> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameB}?> units, {typeNameA}? divisor) =>
|
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /({typeNameA}? dividend, IEnumerable<{typeNameB}> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /({typeNameA}? dividend, IEnumerable<{typeNameB}?> units) =>
|
|
||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonConverter(typeof({typeNameZ}Converter))]
|
|
||||||
public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, IEquatable<{typeNameZ}>, IMensuraUnit
|
public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, IEquatable<{typeNameZ}>, IMensuraUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -403,7 +159,7 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
internal {typeNameZ}(double value) => _Value = value;
|
internal {typeNameZ}(double value) => _Value = value;
|
||||||
|
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] internal {typeNameA} PerValue
|
[NotMapped, JsonIgnore, IgnoreDataMember] internal {typeNameA} PerValue
|
||||||
{ get => ({typeNameA})_Value; init => _Value = (double)value; }
|
{ get => ({typeNameA})_Value; init => _Value = (double)value; }
|
||||||
|
|
||||||
|
|
||||||
@@ -564,57 +320,248 @@ internal static class {typeNameZ}Extensions
|
|||||||
internal static double ToDouble(this {typeNameB}? unit) => unit?._Value ?? 0d;
|
internal static double ToDouble(this {typeNameB}? unit) => unit?._Value ?? 0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class {typeNameZ}Converter : JsonConverter<{typeNameZ}>
|
public readonly partial record struct {typeNameA}
|
||||||
{
|
{
|
||||||
// Используем инвариантную культуру, чтобы разделителем всегда была точка (10.5, а не 10,5)
|
// === Array ===
|
||||||
private static readonly CultureInfo Culture = CultureInfo.InvariantCulture;
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
||||||
|
/({typeNameZ}[] units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
||||||
|
/({typeNameZ}?[] units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
||||||
|
/({typeNameA} dividend, {typeNameZ}[] units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
||||||
|
/({typeNameA} dividend, {typeNameZ}?[] units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameZ}[] units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameZ}?[] units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}?[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameA}? dividend, {typeNameZ}[] units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameA}? dividend, {typeNameZ}?[] units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameB}?[units.Length]);
|
||||||
|
|
||||||
public override {typeNameZ} Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
// === List<T> ===
|
||||||
{
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
||||||
double double_Value;
|
/(List<{typeNameZ}> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
||||||
|
/(List<{typeNameZ}?> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
||||||
|
/({typeNameA} dividend, List<{typeNameZ}> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
||||||
|
/({typeNameA} dividend, List<{typeNameZ}?> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /(List<{typeNameZ}> units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /(List<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}?>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /({typeNameA}? dividend, List<{typeNameZ}> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /({typeNameA}? dividend, List<{typeNameZ}?> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameB}?>(units.Count));
|
||||||
|
|
||||||
if (reader.TokenType == JsonTokenType.String)
|
// === IEnumerable<T> ===
|
||||||
{
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
||||||
// Безопасно парсим double из строки с поддержкой точки как разделителя
|
/(IEnumerable<{typeNameZ}> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
if (!double.TryParse(reader.GetString(), NumberStyles.Float, Culture, out double_Value))
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
||||||
{
|
/(IEnumerable<{typeNameZ}?> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
throw new JsonException($""Не удалось преобразовать строковое значение в double для метрики {nameof({typeNameZ})}."");
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
||||||
}
|
/({typeNameA} dividend, IEnumerable<{typeNameZ}> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
||||||
}
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
||||||
else
|
/({typeNameA} dividend, IEnumerable<{typeNameZ}?> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
||||||
{
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /(IEnumerable<{typeNameZ}> units, {typeNameA}? divisor) =>
|
||||||
// Прямое быстрое чтение числа из JSON
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
||||||
double_Value = reader.GetDouble();
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /(IEnumerable<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameB}?)null : new {typeNameB}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /({typeNameA}? dividend, IEnumerable<{typeNameZ}> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /({typeNameA}? dividend, IEnumerable<{typeNameZ}?> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameB}?)null : new {typeNameB}(0d)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
|
/({typeNameB}[] units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
|
/({typeNameB}?[] units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
|
/({typeNameA} dividend, {typeNameB}[] units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
|
/({typeNameA} dividend, {typeNameB}?[] units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameB}[] units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameB}?[] units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameA}? dividend, {typeNameB}[] units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameA}? dividend, {typeNameB}?[] units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
|
/(List<{typeNameB}> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
|
/(List<{typeNameB}?> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
|
/({typeNameA} dividend, List<{typeNameB}> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
|
/({typeNameA} dividend, List<{typeNameB}?> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameB}> units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameB}?> units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /({typeNameA}? dividend, List<{typeNameB}> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /({typeNameA}? dividend, List<{typeNameB}?> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
|
/(IEnumerable<{typeNameB}> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
|
/(IEnumerable<{typeNameB}?> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
|
/({typeNameA} dividend, IEnumerable<{typeNameB}> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
|
/({typeNameA} dividend, IEnumerable<{typeNameB}?> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameB}> units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameB}?> units, {typeNameA}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /({typeNameA}? dividend, IEnumerable<{typeNameB}> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /({typeNameA}? dividend, IEnumerable<{typeNameB}?> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new(double_Value);
|
public readonly partial record struct {typeNameB}
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, {typeNameZ} value, JsonSerializerOptions options)
|
|
||||||
{
|
{
|
||||||
// Записываем число напрямую в байтовый буфер без выделения памяти под строки
|
public static {typeNameZ} operator /({typeNameA} left, {typeNameB} right) => new(left._Value / right._Value);
|
||||||
writer.WriteNumberValue(value._Value);
|
public static {typeNameZ} operator /({typeNameA}? left, {typeNameB} right) => new(left.Protected() / right._Value);
|
||||||
}
|
public static {typeNameZ} operator /({typeNameA} left, {typeNameB}? right) => new(left._Value / right.Protected());
|
||||||
|
public static {typeNameZ} operator /({typeNameA}? left, {typeNameB}? right) => new(left.Protected() / right.Protected());
|
||||||
|
|
||||||
public override void WriteAsPropertyName(Utf8JsonWriter writer, {typeNameZ} value, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
// Ключи JSON-объектов всегда должны быть строками.
|
|
||||||
// Форматируем double в строку с точкой, чтобы другие сервисы экосистемы прочитали её корректно.
|
|
||||||
// Формат ""R"" (Round-trip) гарантирует, что число не потеряет точность при обратном парсинге.
|
|
||||||
writer.WritePropertyName(value._Value.ToString(""R"", Culture));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override {typeNameZ} ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
// === Array ===
|
||||||
{
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
||||||
string propertyName = reader.GetString()!;
|
*({typeNameZ}[] units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
||||||
|
*({typeNameZ}?[] units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
||||||
|
*({typeNameB} multiplicator, {typeNameZ}[] units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
||||||
|
*({typeNameB} multiplicator, {typeNameZ}?[] units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameZ}[] units, {typeNameB}? multiplicator) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameZ}?[] units, {typeNameB}? multiplicator) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}?[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameB}? multiplicator, {typeNameZ}[] units) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameB}? multiplicator, {typeNameZ}?[] units) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}?[units.Length]);
|
||||||
|
|
||||||
if (!double.TryParse(propertyName, NumberStyles.Float, Culture, out double double_Value))
|
// === List<T> ===
|
||||||
{
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
||||||
throw new JsonException($""Невалидное числовое значение в ключе свойства JSON: '{propertyName}' для метрики {nameof({typeNameZ})}."");
|
*(List<{typeNameZ}> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
}
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
||||||
|
*(List<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
||||||
|
*({typeNameB} multiplicator, List<{typeNameZ}> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
||||||
|
*({typeNameB} multiplicator, List<{typeNameZ}?> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *(List<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *(List<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}?>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *({typeNameB}? multiplicator, List<{typeNameZ}> units) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *({typeNameB}? multiplicator, List<{typeNameZ}?> units) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}?>(units.Count));
|
||||||
|
|
||||||
return new(double_Value);
|
// === IEnumerable<T> ===
|
||||||
}
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
||||||
|
*(IEnumerable<{typeNameZ}> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
||||||
|
*(IEnumerable<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
||||||
|
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
||||||
|
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}?> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *(IEnumerable<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *(IEnumerable<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameA}?)null : new {typeNameA}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *({typeNameB}? multiplicator, IEnumerable<{typeNameZ}> units) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *({typeNameB}? multiplicator, IEnumerable<{typeNameZ}?> units) =>
|
||||||
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameA}?)null : new {typeNameA}(0d)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
|
/({typeNameA}[] units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
|
/({typeNameA}?[] units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
|
/({typeNameB} dividend, {typeNameA}[] units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
|
/({typeNameB} dividend, {typeNameA}?[] units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameA}[] units, {typeNameB}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameA}?[] units, {typeNameB}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameB}? dividend, {typeNameA}[] units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameB}? dividend, {typeNameA}?[] units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new {typeNameZ}?[units.Length]);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
|
/(List<{typeNameA}> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
|
/(List<{typeNameA}?> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
|
/({typeNameB} dividend, List<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
|
/({typeNameB} dividend, List<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameA}> units, {typeNameB}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameA}?> units, {typeNameB}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /({typeNameB}? dividend, List<{typeNameA}> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /({typeNameB}? dividend, List<{typeNameA}?> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : new List<{typeNameZ}?>(units.Count));
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
|
/(IEnumerable<{typeNameA}> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
|
/(IEnumerable<{typeNameA}?> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
|
/({typeNameB} dividend, IEnumerable<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
|
/({typeNameB} dividend, IEnumerable<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameA}> units, {typeNameB}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameA}?> units, {typeNameB}? divisor) =>
|
||||||
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /({typeNameB}? dividend, IEnumerable<{typeNameA}> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /({typeNameB}? dividend, IEnumerable<{typeNameA}?> units) =>
|
||||||
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameZ}?)null : new {typeNameZ}(0d)));
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Microsoft.CodeAnalysis.Text;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace G;
|
namespace G;
|
||||||
@@ -20,12 +19,9 @@ public class TestsGenerator : IIncrementalGenerator
|
|||||||
|
|
||||||
context.RegisterSourceOutput(compilationProvider, (spc, compilation) =>
|
context.RegisterSourceOutput(compilationProvider, (spc, compilation) =>
|
||||||
{
|
{
|
||||||
// Генерируем тесты только если это тестовый проект
|
if (compilation.AssemblyName == null || !compilation.AssemblyName.EndsWith(".Tests"))
|
||||||
var assemblyName = compilation.AssemblyName;
|
|
||||||
if (assemblyName == null || !assemblyName.EndsWith(".Tests"))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Находим основную сборку
|
|
||||||
var mensuraAssembly = compilation.References
|
var mensuraAssembly = compilation.References
|
||||||
.Select(r => compilation.GetAssemblyOrModuleSymbol(r) as IAssemblySymbol)
|
.Select(r => compilation.GetAssemblyOrModuleSymbol(r) as IAssemblySymbol)
|
||||||
.FirstOrDefault(a => a?.Name == "QWERTYkez.Mensura" || a?.Name?.EndsWith(".Mensura") == true);
|
.FirstOrDefault(a => a?.Name == "QWERTYkez.Mensura" || a?.Name?.EndsWith(".Mensura") == true);
|
||||||
@@ -33,7 +29,6 @@ public class TestsGenerator : IIncrementalGenerator
|
|||||||
if (mensuraAssembly == null)
|
if (mensuraAssembly == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Собираем типы с атрибутами
|
|
||||||
var targetTypes = new List<INamedTypeSymbol>();
|
var targetTypes = new List<INamedTypeSymbol>();
|
||||||
CollectTypesWithAttribute(mensuraAssembly.GlobalNamespace, targetTypes, UnitAttributeFullName);
|
CollectTypesWithAttribute(mensuraAssembly.GlobalNamespace, targetTypes, UnitAttributeFullName);
|
||||||
CollectTypesWithAttribute(mensuraAssembly.GlobalNamespace, targetTypes, ComplexAttributeFullName);
|
CollectTypesWithAttribute(mensuraAssembly.GlobalNamespace, targetTypes, ComplexAttributeFullName);
|
||||||
@@ -43,79 +38,57 @@ public class TestsGenerator : IIncrementalGenerator
|
|||||||
|
|
||||||
foreach (var type in targetTypes)
|
foreach (var type in targetTypes)
|
||||||
{
|
{
|
||||||
var typeName = type.Name;
|
|
||||||
var unitProperties = GetStaticProperties(type);
|
var unitProperties = GetStaticProperties(type);
|
||||||
var firstNonBaseProp = unitProperties.FirstOrDefault(p => !p.Name.StartsWith("_"));
|
if (unitProperties.Length == 0) continue;
|
||||||
|
var firstNonBase = unitProperties.FirstOrDefault(p => !p.Name.StartsWith("_"));
|
||||||
|
if (firstNonBase.Name == null) continue;
|
||||||
|
|
||||||
|
// Генерируем два файла
|
||||||
|
GenerateSerializationTest(spc, type.Name, firstNonBase.Name, "SystemText", "System.Text.Json");
|
||||||
|
GenerateSerializationTest(spc, type.Name, firstNonBase.Name, "Newtonsoft", "Newtonsoft.Json");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GenerateSerializationTest(SourceProductionContext spc, string typeName, string unitName, string framework, string namespaceName)
|
||||||
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine("// <auto-generated/>");
|
sb.AppendLine("// <auto-generated/>");
|
||||||
sb.AppendLine("#pragma warning disable");
|
sb.AppendLine("#pragma warning disable");
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine("using Xunit;");
|
sb.AppendLine("using Xunit;");
|
||||||
|
sb.AppendLine($"using {namespaceName};");
|
||||||
sb.AppendLine("using QWERTYkez.Mensura.Units;");
|
sb.AppendLine("using QWERTYkez.Mensura.Units;");
|
||||||
sb.AppendLine("using QWERTYkez.Mensura.Extensions;");
|
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine($"namespace QWERTYkez.Mensura.Tests");
|
sb.AppendLine($"namespace QWERTYkez.Mensura.Tests");
|
||||||
sb.AppendLine("{");
|
sb.AppendLine("{");
|
||||||
sb.AppendLine($" public class {typeName}Tests");
|
sb.AppendLine($" public class {typeName}Serialization_{framework}Tests");
|
||||||
sb.AppendLine(" {");
|
sb.AppendLine(" {");
|
||||||
sb.AppendLine($" private const double Tolerance = 1e-12;");
|
sb.AppendLine($" private const double Tolerance = 1e-12;");
|
||||||
|
sb.AppendLine($" private readonly {typeName} _testValue = {typeName}.{unitName};");
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
|
|
||||||
// Тест значения по умолчанию
|
// Тест
|
||||||
sb.AppendLine($" [Fact]");
|
sb.AppendLine(" [Fact]");
|
||||||
sb.AppendLine($" public void Default_ValueIsZero()");
|
sb.AppendLine($" public void {framework}_SerializeDeserialize_ReturnsEqualValue()");
|
||||||
sb.AppendLine($" {{");
|
sb.AppendLine(" {");
|
||||||
sb.AppendLine($" var unit = new {typeName}();");
|
if (framework == "SystemText")
|
||||||
sb.AppendLine($" Assert.Equal(0, (double)unit, Tolerance);");
|
|
||||||
sb.AppendLine($" }}");
|
|
||||||
sb.AppendLine();
|
|
||||||
|
|
||||||
// Тесты статических свойств (единиц)
|
|
||||||
foreach (var prop in unitProperties)
|
|
||||||
{
|
{
|
||||||
bool isBase = prop.Name.StartsWith("_");
|
sb.AppendLine(" var json = System.Text.Json.JsonSerializer.Serialize(_testValue);");
|
||||||
sb.AppendLine($" [Fact]");
|
sb.AppendLine($" var deserialized = System.Text.Json.JsonSerializer.Deserialize<{typeName}>(json);");
|
||||||
sb.AppendLine($" public void {prop.Name}_IsCorrect()");
|
|
||||||
sb.AppendLine($" {{");
|
|
||||||
sb.AppendLine($" var unit = {typeName}.{prop.Name};");
|
|
||||||
if (isBase)
|
|
||||||
{
|
|
||||||
sb.AppendLine($" Assert.Equal(1, (double)unit, Tolerance);");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.AppendLine($" Assert.True((double)unit > 0);");
|
sb.AppendLine(" var json = Newtonsoft.Json.JsonConvert.SerializeObject(_testValue);");
|
||||||
|
sb.AppendLine($" var deserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<{typeName}>(json);");
|
||||||
}
|
}
|
||||||
sb.AppendLine($" }}");
|
sb.AppendLine(" Assert.Equal((double)_testValue, (double)deserialized, Tolerance);");
|
||||||
|
sb.AppendLine(" }");
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
}
|
|
||||||
|
|
||||||
// Тесты коллекционных методов
|
|
||||||
if (unitProperties.Length > 0 && firstNonBaseProp.Name != null)
|
|
||||||
{
|
|
||||||
sb.AppendLine($" [Fact]");
|
|
||||||
sb.AppendLine($" public void CollectionOperations_Work()");
|
|
||||||
sb.AppendLine($" {{");
|
|
||||||
sb.AppendLine($" var first = {typeName}.{firstNonBaseProp.Name};");
|
|
||||||
sb.AppendLine($" var items = new[] {{ first, first }};");
|
|
||||||
sb.AppendLine($" var sum = items.Sum();");
|
|
||||||
sb.AppendLine($" Assert.True((double)sum > 0);");
|
|
||||||
sb.AppendLine($" var avg = items.Average();");
|
|
||||||
sb.AppendLine($" Assert.True((double)avg > 0);");
|
|
||||||
sb.AppendLine($" var max = items.Max();");
|
|
||||||
sb.AppendLine($" Assert.True((double)max > 0);");
|
|
||||||
sb.AppendLine($" var min = items.Min();");
|
|
||||||
sb.AppendLine($" Assert.True((double)min > 0);");
|
|
||||||
sb.AppendLine($" }}");
|
|
||||||
sb.AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.AppendLine(" }");
|
sb.AppendLine(" }");
|
||||||
sb.AppendLine("}");
|
sb.AppendLine("}");
|
||||||
spc.AddSource($"{typeName}Tests.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
|
||||||
}
|
spc.AddSource($"Serialize.{framework}.{typeName}.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CollectTypesWithAttribute(INamespaceSymbol ns, List<INamedTypeSymbol> results, string attributeFullName)
|
private static void CollectTypesWithAttribute(INamespaceSymbol ns, List<INamedTypeSymbol> results, string attributeFullName)
|
||||||
@@ -154,7 +127,7 @@ public class TestsGenerator : IIncrementalGenerator
|
|||||||
props.Add(new UnitProperty(propName, prop.Type.ToString()));
|
props.Add(new UnitProperty(propName, prop.Type.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [.. props];
|
return props.ToImmutableArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly struct UnitProperty
|
private readonly struct UnitProperty
|
||||||
|
|||||||
@@ -98,9 +98,7 @@ using System.Runtime.Serialization;
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura.Units;
|
namespace QWERTYkez.Mensura.Units;
|
||||||
|
|
||||||
public class {typeName}Converter : UnitJsonConverter<{typeName}> { }
|
[Newtonsoft.Json.JsonConverter(typeof(NewtonsoftUnitConverter<{typeName}>)), JsonConverter(typeof(UnitJsonConverter<{typeName}>))]
|
||||||
|
|
||||||
[JsonConverter(typeof({typeName}Converter))]
|
|
||||||
public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEquatable<{typeName}>, IMensuraUnit
|
public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEquatable<{typeName}>, IMensuraUnit
|
||||||
{
|
{
|
||||||
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
||||||
@@ -115,6 +113,21 @@ public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEq
|
|||||||
public bool Equals({typeName}? other) => _Value.Equals(other?._Value);
|
public bool Equals({typeName}? other) => _Value.Equals(other?._Value);
|
||||||
|
|
||||||
|
|
||||||
|
public static explicit operator {typeName}(double val) => Unsafe.As<double, {typeName}>(ref val);
|
||||||
|
public static explicit operator double({typeName} unit) => unit._Value;
|
||||||
|
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public {typeName} Abs() => new(Math.Abs(_Value));
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
internal R Pow2_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => (_Value * _Value).ToUnit<R>();
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
internal R Sqrt_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => Math.Sqrt(_Value).ToUnit<R>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0;
|
[JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0;
|
||||||
[JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0;
|
[JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0;
|
||||||
[JsonIgnore, IgnoreDataMember] public bool IsNegative => double.IsNegative(_Value);
|
[JsonIgnore, IgnoreDataMember] public bool IsNegative => double.IsNegative(_Value);
|
||||||
@@ -269,19 +282,6 @@ public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEq
|
|||||||
public static {typeName} operator /({typeName} T1, UInt128 T2) => T1 / T2.ToDouble();
|
public static {typeName} operator /({typeName} T1, UInt128 T2) => T1 / T2.ToDouble();
|
||||||
public static {typeName} operator /({typeName} T1, UInt128? T2) => T1 / T2.ToDouble();
|
public static {typeName} operator /({typeName} T1, UInt128? T2) => T1 / T2.ToDouble();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public static explicit operator {typeName}(double val) => Unsafe.As<double, {typeName}>(ref val);
|
|
||||||
public static explicit operator double({typeName} unit) => unit._Value;
|
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public {typeName} Abs() => new(Math.Abs(_Value));
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
internal R Pow2_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => (_Value * _Value).ToUnit<R>();
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
internal R Sqrt_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => Math.Sqrt(_Value).ToUnit<R>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class {typeName}Extensions
|
public static class {typeName}Extensions
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
98
QWERTYkez.Mensura/Newtonsoft.cs
Normal file
98
QWERTYkez.Mensura/Newtonsoft.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace QWERTYkez.Mensura;
|
||||||
|
|
||||||
|
internal static class MensuraBinder
|
||||||
|
{
|
||||||
|
// Атрибут заставляет .NET автоматически выполнить этот метод при загрузке вашей DLL
|
||||||
|
#pragma warning disable CA2255 // Атрибут "ModuleInitializer" не должен использоваться в библиотеках
|
||||||
|
[ModuleInitializer]
|
||||||
|
#pragma warning restore CA2255 // Атрибут "ModuleInitializer" не должен использоваться в библиотеках
|
||||||
|
internal static void Initialize()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Проверяем, загружена ли вообще сборка Newtonsoft в текущем приложении
|
||||||
|
bool isNewtonsoftLoaded = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.Any(a => a.GetName().Name == "Newtonsoft.Json");
|
||||||
|
|
||||||
|
if (!isNewtonsoftLoaded) return;
|
||||||
|
|
||||||
|
// Если Newtonsoft есть в приложении, безопасно регистрируем наш generic-конвертер
|
||||||
|
RegisterConverters();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Игнорируем любые ошибки, чтобы не сломать основное приложение
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Выносим работу с типами Newtonsoft в отдельный метод.
|
||||||
|
// Это критически важно! Если бы этот код был внутри Initialize(),
|
||||||
|
// рантайм упал бы еще при входе в Initialize().
|
||||||
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
|
private static void RegisterConverters()
|
||||||
|
{
|
||||||
|
// Добавляем конвертер в глобальные настройки по умолчанию внешнего Newtonsoft.Json
|
||||||
|
var currentSettingsFactory = JsonConvert.DefaultSettings;
|
||||||
|
|
||||||
|
JsonConvert.DefaultSettings = () =>
|
||||||
|
{
|
||||||
|
// Берем старые настройки или создаем чистые
|
||||||
|
var settings = currentSettingsFactory?.Invoke() ?? new JsonSerializerSettings();
|
||||||
|
|
||||||
|
???????????
|
||||||
|
// https://www.google.com/search?mtid=nSMmasO9AbK6wPAPq4SMKA&ved=2ahUKEwi3uqDMxvaUAxUOGhAIHWz7OfgQoo4PegYIAggAEAI&q=var+json1+%3D+System.Text.Json.JsonSerializer.Serialize%28_testValue%29%3B+%2F%2F+60%0A++++++++var+json2+%3D+Newtonsoft.Json.JsonConvert.SerializeObject%28_testValue%29%3B+%2F%2F+%7B%7D%0A%0A++++%5BJsonInclude%2C+DataMember%2C+JsonPropertyName%28%22v%22%29%2C+Obsolete%5D%0A++++internal+double+Value+%7B+get+%3D%3E+_Value%3B+init+%3D%3E+_Value+%3D+value%3B+%7D%0A++++internal+readonly+double+_Value%3B%0A%0A%D0%BC%D0%BE%D0%B6%D0%BD%D0%BE+%D0%BB%D0%B8+%D0%BD%D0%B5+%D0%B4%D0%BE%D0%B1%D0%B0%D0%B2%D0%BB%D1%8F%D1%8F+%D0%B7%D0%B0%D0%B2%D0%B8%D1%81%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D1%8C+Newtonsoft.Json+%D0%B2+%D0%BE%D1%81%D0%BD%D0%BE%D0%B2%D0%BD%D1%83%D1%8E+%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA%D1%83%0A%D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D0%BB%D1%8C%D0%BD%D0%BE+%D1%81%D0%B5%D1%80%D0%B8%D0%B0%D0%BB%D0%B8%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D1%8C+%D0%BE%D0%B1%D1%8A%D0%B5%D0%BA%D1%82%D1%8B+%D0%B2%D0%BE+%D0%B2%D0%BD%D0%B5%D1%88%D0%BD%D0%B5%D0%BC+%D0%BA%D0%BE%D0%B4%D0%B5%2C+%D1%87%D1%82%D0%BE%D0%B1%D1%8B+%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0%D0%BB%D0%BE+%22%D0%B8%D0%B7+%D0%BA%D0%BE%D1%80%D0%BE%D0%B1%D0%BA%D0%B8%22%3F&mstk=AUtExfAYU_oj2WXNVX-yyCIyGikGi_SP9UgYVJZHrC_1QDUiSGIypGAvXnteDNaWaCTYlzJI-o3lN8V6c0rIaNM4Z594r_Cci9-tDOQPKNXlesQFCokO1LoCsqplwQwAMz-iYsR4mjWCpyZBdMuOtTN7Y-D4BFkxIlXPn53SCTiVWZDHkCkag6egP75rWkXMLV0mmCOxsNwDJybXD9w6zvETdAGVG6uxn97YRSCeCt7XHy8NVaG1CtR9BnH-2kpkVbtae4g1ZGTaqcsUynXbza3X5GMtB30L_91rmfI&csuir=1&udm=50
|
||||||
|
|
||||||
|
// Добавляем наш быстрый generic-конвертер для Angle
|
||||||
|
// (Если у вас есть другие физические величины — добавьте их сюда же через запятую)
|
||||||
|
settings.Converters.Add(new NewtonsoftUnitConverter<Angle>());
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NewtonsoftUnitConverter<U> : Newtonsoft.Json.JsonConverter<U> where U : struct, IMensuraUnit, IEquatable<U>
|
||||||
|
{
|
||||||
|
// СЕРИАЛИЗАЦИЯ: вызывается автоматически при записи объекта во внешнем коде
|
||||||
|
public override void WriteJson(JsonWriter writer, U value, Newtonsoft.Json.JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
var numericValue = value.ToDouble();
|
||||||
|
|
||||||
|
// Проверяем, является ли число целым (остаток от деления на 1 равен 0)
|
||||||
|
if (numericValue % 1 == 0)
|
||||||
|
{
|
||||||
|
// Записываем как long — Newtonsoft уберет ".0" и выдаст просто 60
|
||||||
|
writer.WriteValue((long)numericValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Если есть дробная часть (например, 60.5) — записываем как double
|
||||||
|
writer.WriteValue(numericValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ДЕСЕРИАЛИЗАЦИЯ: вызывается автоматически при чтении объекта из JSON
|
||||||
|
public override U ReadJson(JsonReader reader, Type objectType, U existingValue, bool hasExistingValue, Newtonsoft.Json.JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
// Если в JSON пришел null (для Nullable<U>), возвращаем дефолтную структуру
|
||||||
|
if (reader.TokenType == JsonToken.Null)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Читаем сырое число из потока. Newtonsoft автоматически парсит его как double или long
|
||||||
|
if (reader.Value is null)
|
||||||
|
{
|
||||||
|
throw new JsonSerializationException($"Не удалось десериализовать тип {typeof(U).Name}: значение отсутствует.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Приводим к double с учетом инвариантной культуры
|
||||||
|
double numericValue = Convert.ToDouble(reader.Value, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
// Создаем вашу структуру.
|
||||||
|
return numericValue.ToUnit<U>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,6 +50,10 @@
|
|||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
<NoWarn>1701;1702;IDE1006</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\QWERTYkez.Mensura.Generator\QWERTYkez.Mensura.Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
<ProjectReference Include="..\QWERTYkez.Mensura.Generator\QWERTYkez.Mensura.Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura;
|
namespace QWERTYkez.Mensura;
|
||||||
|
|
||||||
public class UnitJsonConverter<T> : JsonConverter<T> where T : struct, IMensuraUnit, IEquatable<T>
|
public class UnitJsonConverter<U> : JsonConverter<U> where U : struct, IMensuraUnit, IEquatable<U>
|
||||||
{
|
{
|
||||||
// Используем инвариантную культуру, чтобы разделителем всегда была точка (10.5, а не 10,5)
|
// Используем инвариантную культуру, чтобы разделителем всегда была точка (10.5, а не 10,5)
|
||||||
private static readonly CultureInfo Culture = CultureInfo.InvariantCulture;
|
private static readonly CultureInfo Culture = CultureInfo.InvariantCulture;
|
||||||
|
|
||||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override U Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
double double_Value;
|
double double_Value;
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ public class UnitJsonConverter<T> : JsonConverter<T> where T : struct, IMensuraU
|
|||||||
// Безопасно парсим double из строки с поддержкой точки как разделителя
|
// Безопасно парсим double из строки с поддержкой точки как разделителя
|
||||||
if (!double.TryParse(reader.GetString(), NumberStyles.Float, Culture, out double_Value))
|
if (!double.TryParse(reader.GetString(), NumberStyles.Float, Culture, out double_Value))
|
||||||
{
|
{
|
||||||
throw new JsonException($"Не удалось преобразовать строковое значение в double для метрики {nameof(T)}.");
|
throw new JsonException($"Не удалось преобразовать строковое значение в double для метрики {nameof(U)}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -25,16 +25,16 @@ public class UnitJsonConverter<T> : JsonConverter<T> where T : struct, IMensuraU
|
|||||||
double_Value = reader.GetDouble();
|
double_Value = reader.GetDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
return double_Value.ToUnit<T>();
|
return double_Value.ToUnit<U>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
public override void Write(Utf8JsonWriter writer, U value, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
// Записываем число напрямую в байтовый буфер без выделения памяти под строки
|
// Записываем число напрямую в байтовый буфер без выделения памяти под строки
|
||||||
writer.WriteNumberValue(value.ToDouble());
|
writer.WriteNumberValue(value.ToDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void WriteAsPropertyName(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
public override void WriteAsPropertyName(Utf8JsonWriter writer, U value, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
// Ключи JSON-объектов всегда должны быть строками.
|
// Ключи JSON-объектов всегда должны быть строками.
|
||||||
// Форматируем double в строку с точкой, чтобы другие сервисы экосистемы прочитали её корректно.
|
// Форматируем double в строку с точкой, чтобы другие сервисы экосистемы прочитали её корректно.
|
||||||
@@ -42,15 +42,15 @@ public class UnitJsonConverter<T> : JsonConverter<T> where T : struct, IMensuraU
|
|||||||
writer.WritePropertyName(value.ToDouble().ToString("R", Culture));
|
writer.WritePropertyName(value.ToDouble().ToString("R", Culture));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override U ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
string propertyName = reader.GetString()!;
|
string propertyName = reader.GetString()!;
|
||||||
|
|
||||||
if (!double.TryParse(propertyName, NumberStyles.Float, Culture, out double double_Value))
|
if (!double.TryParse(propertyName, NumberStyles.Float, Culture, out double double_Value))
|
||||||
{
|
{
|
||||||
throw new JsonException($"Невалидное числовое значение в ключе свойства JSON: '{propertyName}' для метрики {nameof(T)}.");
|
throw new JsonException($"Невалидное числовое значение в ключе свойства JSON: '{propertyName}' для метрики {nameof(U)}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return double_Value.ToUnit<T>();
|
return double_Value.ToUnit<U>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Angle
|
public readonly partial record struct Angle
|
||||||
{
|
{
|
||||||
public static Angle _Second { get; } = new() { _Seconds = 1 };
|
public static Angle _Second { get; } = new() { _Seconds = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _Seconds { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _Seconds { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Angle Minute { get; } = new() { Minutes = 1 };
|
public static Angle Minute { get; } = new() { Minutes = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Minutes
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Minutes
|
||||||
{
|
{
|
||||||
get => AngleConv.Minutes.From(_Value);
|
get => AngleConv.Minutes.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Angle
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Angle Degree { get; } = new() { Degrees = 1 };
|
public static Angle Degree { get; } = new() { Degrees = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Degrees
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Degrees
|
||||||
{
|
{
|
||||||
get => AngleConv.Degrees.From(_Value);
|
get => AngleConv.Degrees.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -31,7 +31,7 @@ public readonly partial record struct Angle
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Angle Radian { get; } = new() { Radians = 1 };
|
public static Angle Radian { get; } = new() { Radians = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Radians
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Radians
|
||||||
{
|
{
|
||||||
get => AngleConv.Radians.From(_Value);
|
get => AngleConv.Radians.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Area
|
public readonly partial record struct Area
|
||||||
{
|
{
|
||||||
public static Area _MilliMeterSquared { get; } = new() { _MilliMetersSquared = 1 };
|
public static Area _MilliMeterSquared { get; } = new() { _MilliMetersSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _MilliMetersSquared { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMetersSquared { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Area CentiMeterSquared { get; } = new() { CentiMetersSquared = 1 };
|
public static Area CentiMeterSquared { get; } = new() { CentiMetersSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double CentiMetersSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double CentiMetersSquared
|
||||||
{
|
{
|
||||||
get => AreaConv.CentiMetersSquared.From(_Value);
|
get => AreaConv.CentiMetersSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Area
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Area MeterSquared { get; } = new() { MetersSquared = 1 };
|
public static Area MeterSquared { get; } = new() { MetersSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double MetersSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double MetersSquared
|
||||||
{
|
{
|
||||||
get => AreaConv.MetersSquared.From(_Value);
|
get => AreaConv.MetersSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -31,7 +31,7 @@ public readonly partial record struct Area
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Area Hector { get; } = new() { Hectors = 1 };
|
public static Area Hector { get; } = new() { Hectors = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Hectors
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Hectors
|
||||||
{
|
{
|
||||||
get => AreaConv.Hectors.From(_Value);
|
get => AreaConv.Hectors.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -41,7 +41,7 @@ public readonly partial record struct Area
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Area KiloMeterSquared { get; } = new() { KiloMetersSquared = 1 };
|
public static Area KiloMeterSquared { get; } = new() { KiloMetersSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloMetersSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloMetersSquared
|
||||||
{
|
{
|
||||||
get => AreaConv.KiloMetersSquared.From(_Value);
|
get => AreaConv.KiloMetersSquared.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Boost
|
public readonly partial record struct Boost
|
||||||
{
|
{
|
||||||
public static Boost _MeterPerSecondSquared { get; } = new() { _MetersPerSecondSquared = 1 };
|
public static Boost _MeterPerSecondSquared { get; } = new() { _MetersPerSecondSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _MetersPerSecondSquared { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _MetersPerSecondSquared { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Boost KiloMeterPerSecondSquared { get; } = new() { KiloMetersPerSecondSquared = 1 };
|
public static Boost KiloMeterPerSecondSquared { get; } = new() { KiloMetersPerSecondSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloMetersPerSecondSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloMetersPerSecondSquared
|
||||||
{
|
{
|
||||||
get => BoostConv.KiloMetersPerSecondSquared.From(_Value);
|
get => BoostConv.KiloMetersPerSecondSquared.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -267,7 +267,7 @@
|
|||||||
// internal ZZZZZZZZZZZZZZZZ(double value) => _Value = value;
|
// internal ZZZZZZZZZZZZZZZZ(double value) => _Value = value;
|
||||||
|
|
||||||
|
|
||||||
// [NotMapped, JsonIgnore] internal AAAAAAAAAAAAAAAA PerValue
|
// [NotMapped, JsonIgnore, IgnoreDataMember] internal AAAAAAAAAAAAAAAA PerValue
|
||||||
// { get => (AAAAAAAAAAAAAAAA)_Value; init => _Value = (double)value; }
|
// { get => (AAAAAAAAAAAAAAAA)_Value; init => _Value = (double)value; }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
// public static ZZZZZZZZZZZZZZZZ KiloGramPerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloGrams = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ KiloGramPerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloGrams = 1 } };
|
||||||
// public static ZZZZZZZZZZZZZZZZ CentnerPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Centners = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ CentnerPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Centners = 1 } };
|
||||||
// public static ZZZZZZZZZZZZZZZZ TonPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Tons = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ TonPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Tons = 1 } };
|
||||||
// [NotMapped, JsonIgnore] public AAAAAAAAAAAAAAAA _PerMilliMeter
|
// [NotMapped, JsonIgnore, IgnoreDataMember] public AAAAAAAAAAAAAAAA _PerMilliMeter
|
||||||
// { get => (AAAAAAAAAAAAAAAA)_Value; init => _Value = (double)value; }
|
// { get => (AAAAAAAAAAAAAAAA)_Value; init => _Value = (double)value; }
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
// public static ZZZZZZZZZZZZZZZZ KiloGramPerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloGrams = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ KiloGramPerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloGrams = 1 } };
|
||||||
// public static ZZZZZZZZZZZZZZZZ CentnerPerCentiMeter { get; } = new() { PerCentiMeter = new() { Centners = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ CentnerPerCentiMeter { get; } = new() { PerCentiMeter = new() { Centners = 1 } };
|
||||||
// public static ZZZZZZZZZZZZZZZZ TonPerCentiMeter { get; } = new() { PerCentiMeter = new() { Tons = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ TonPerCentiMeter { get; } = new() { PerCentiMeter = new() { Tons = 1 } };
|
||||||
// [NotMapped, JsonIgnore] public AAAAAAAAAAAAAAAA PerCentiMeter
|
// [NotMapped, JsonIgnore, IgnoreDataMember] public AAAAAAAAAAAAAAAA PerCentiMeter
|
||||||
// {
|
// {
|
||||||
// get => new(_Value * BBBBBBBBBBBBBBBBConv.CentiMeters.Multiplicator);
|
// get => new(_Value * BBBBBBBBBBBBBBBBConv.CentiMeters.Multiplicator);
|
||||||
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.CentiMeters.Multiplicator;
|
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.CentiMeters.Multiplicator;
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
// public static ZZZZZZZZZZZZZZZZ CentnerPerDeciMeter { get; } = new() { PerDeciMeter = new() { Centners = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ CentnerPerDeciMeter { get; } = new() { PerDeciMeter = new() { Centners = 1 } };
|
||||||
// public static ZZZZZZZZZZZZZZZZ TonPerDeciMeter { get; } = new() { PerDeciMeter = new() { Tons = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ TonPerDeciMeter { get; } = new() { PerDeciMeter = new() { Tons = 1 } };
|
||||||
|
|
||||||
// [NotMapped, JsonIgnore] public AAAAAAAAAAAAAAAA PerDeciMeter
|
// [NotMapped, JsonIgnore, IgnoreDataMember] public AAAAAAAAAAAAAAAA PerDeciMeter
|
||||||
// {
|
// {
|
||||||
// get => new(_Value * BBBBBBBBBBBBBBBBConv.DeciMeters.Multiplicator);
|
// get => new(_Value * BBBBBBBBBBBBBBBBConv.DeciMeters.Multiplicator);
|
||||||
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.DeciMeters.Multiplicator;
|
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.DeciMeters.Multiplicator;
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
// public static ZZZZZZZZZZZZZZZZ CentnerPerMeter { get; } = new() { PerMeter = new() { Centners = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ CentnerPerMeter { get; } = new() { PerMeter = new() { Centners = 1 } };
|
||||||
// public static ZZZZZZZZZZZZZZZZ TonPerMeter { get; } = new() { PerMeter = new() { Tons = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ TonPerMeter { get; } = new() { PerMeter = new() { Tons = 1 } };
|
||||||
|
|
||||||
// [NotMapped, JsonIgnore] public AAAAAAAAAAAAAAAA PerMeter
|
// [NotMapped, JsonIgnore, IgnoreDataMember] public AAAAAAAAAAAAAAAA PerMeter
|
||||||
// {
|
// {
|
||||||
// get => new(_Value * BBBBBBBBBBBBBBBBConv.Meters.Multiplicator);
|
// get => new(_Value * BBBBBBBBBBBBBBBBConv.Meters.Multiplicator);
|
||||||
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.Meters.Multiplicator;
|
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.Meters.Multiplicator;
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
// public static ZZZZZZZZZZZZZZZZ CentnerPerKiloMeter { get; } = new() { PerKiloMeter = new() { Centners = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ CentnerPerKiloMeter { get; } = new() { PerKiloMeter = new() { Centners = 1 } };
|
||||||
// public static ZZZZZZZZZZZZZZZZ TonPerKiloMeter { get; } = new() { PerKiloMeter = new() { Tons = 1 } };
|
// public static ZZZZZZZZZZZZZZZZ TonPerKiloMeter { get; } = new() { PerKiloMeter = new() { Tons = 1 } };
|
||||||
|
|
||||||
// [NotMapped, JsonIgnore] public AAAAAAAAAAAAAAAA PerKiloMeter
|
// [NotMapped, JsonIgnore, IgnoreDataMember] public AAAAAAAAAAAAAAAA PerKiloMeter
|
||||||
// {
|
// {
|
||||||
// get => new(_Value * BBBBBBBBBBBBBBBBConv.KiloMeters.Multiplicator);
|
// get => new(_Value * BBBBBBBBBBBBBBBBConv.KiloMeters.Multiplicator);
|
||||||
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.KiloMeters.Multiplicator;
|
// init => _Value = value._Value / BBBBBBBBBBBBBBBBConv.KiloMeters.Multiplicator;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
public static ForceLinear KiloGramForcePerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloGramForces = 1 } };
|
public static ForceLinear KiloGramForcePerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloGramForces = 1 } };
|
||||||
public static ForceLinear KiloNewtonPerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloNewtons = 1 } };
|
public static ForceLinear KiloNewtonPerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloNewtons = 1 } };
|
||||||
public static ForceLinear TonForcePerMilliMeter { get; } = new() { _PerMilliMeter = new() { TonForces = 1 } };
|
public static ForceLinear TonForcePerMilliMeter { get; } = new() { _PerMilliMeter = new() { TonForces = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Force _PerMilliMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force _PerMilliMeter
|
||||||
{ get => (Force)_Value; init => _Value = (double)value; }
|
{ get => (Force)_Value; init => _Value = (double)value; }
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
public static ForceLinear KiloGramForcePerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloGramForces = 1 } };
|
public static ForceLinear KiloGramForcePerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloGramForces = 1 } };
|
||||||
public static ForceLinear KiloNewtonPerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloNewtons = 1 } };
|
public static ForceLinear KiloNewtonPerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloNewtons = 1 } };
|
||||||
public static ForceLinear TonForcePerCentiMeter { get; } = new() { PerCentiMeter = new() { TonForces = 1 } };
|
public static ForceLinear TonForcePerCentiMeter { get; } = new() { PerCentiMeter = new() { TonForces = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Force PerCentiMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force PerCentiMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.CentiMeters.Multiplicator);
|
get => new(_Value * LengthConv.CentiMeters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.CentiMeters.Multiplicator;
|
init => _Value = value._Value / LengthConv.CentiMeters.Multiplicator;
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
public static ForceLinear KiloNewtonPerDeciMeter { get; } = new() { PerDeciMeter = new() { KiloNewtons = 1 } };
|
public static ForceLinear KiloNewtonPerDeciMeter { get; } = new() { PerDeciMeter = new() { KiloNewtons = 1 } };
|
||||||
public static ForceLinear TonForcePerDeciMeter { get; } = new() { PerDeciMeter = new() { TonForces = 1 } };
|
public static ForceLinear TonForcePerDeciMeter { get; } = new() { PerDeciMeter = new() { TonForces = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Force PerDeciMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force PerDeciMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.DeciMeters.Multiplicator);
|
get => new(_Value * LengthConv.DeciMeters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.DeciMeters.Multiplicator;
|
init => _Value = value._Value / LengthConv.DeciMeters.Multiplicator;
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
public static ForceLinear KiloNewtonPerMeter { get; } = new() { PerMeter = new() { KiloNewtons = 1 } };
|
public static ForceLinear KiloNewtonPerMeter { get; } = new() { PerMeter = new() { KiloNewtons = 1 } };
|
||||||
public static ForceLinear TonForcePerMeter { get; } = new() { PerMeter = new() { TonForces = 1 } };
|
public static ForceLinear TonForcePerMeter { get; } = new() { PerMeter = new() { TonForces = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Force PerMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force PerMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.Meters.Multiplicator);
|
get => new(_Value * LengthConv.Meters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.Meters.Multiplicator;
|
init => _Value = value._Value / LengthConv.Meters.Multiplicator;
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
public static ForceLinear KiloNewtonPerKiloMeter { get; } = new() { PerKiloMeter = new() { KiloNewtons = 1 } };
|
public static ForceLinear KiloNewtonPerKiloMeter { get; } = new() { PerKiloMeter = new() { KiloNewtons = 1 } };
|
||||||
public static ForceLinear TonForcePerKiloMeter { get; } = new() { PerKiloMeter = new() { TonForces = 1 } };
|
public static ForceLinear TonForcePerKiloMeter { get; } = new() { PerKiloMeter = new() { TonForces = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Force PerKiloMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force PerKiloMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.KiloMeters.Multiplicator);
|
get => new(_Value * LengthConv.KiloMeters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.KiloMeters.Multiplicator;
|
init => _Value = value._Value / LengthConv.KiloMeters.Multiplicator;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
public static ForceVolumetric KiloGramForcePerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { KiloGramForces = 1 } };
|
public static ForceVolumetric KiloGramForcePerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { KiloGramForces = 1 } };
|
||||||
public static ForceVolumetric KiloNewtonPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { KiloNewtons = 1 } };
|
public static ForceVolumetric KiloNewtonPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { KiloNewtons = 1 } };
|
||||||
public static ForceVolumetric TonForcePerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { TonForces = 1 } };
|
public static ForceVolumetric TonForcePerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { TonForces = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Force _PerMilliMeterCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force _PerMilliMeterCubic
|
||||||
{ get => (Force)_Value; init => _Value = (double)value; }
|
{ get => (Force)_Value; init => _Value = (double)value; }
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
public static ForceVolumetric KiloGramForcePerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { KiloGramForces = 1 } };
|
public static ForceVolumetric KiloGramForcePerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { KiloGramForces = 1 } };
|
||||||
public static ForceVolumetric KiloNewtonPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { KiloNewtons = 1 } };
|
public static ForceVolumetric KiloNewtonPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { KiloNewtons = 1 } };
|
||||||
public static ForceVolumetric TonForcePerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { TonForces = 1 } };
|
public static ForceVolumetric TonForcePerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { TonForces = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Force PerCentiMeterCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force PerCentiMeterCubic
|
||||||
{
|
{
|
||||||
get => new(_Value * VolumeConv.CentiMetersCubic.Multiplicator);
|
get => new(_Value * VolumeConv.CentiMetersCubic.Multiplicator);
|
||||||
init => _Value = value._Value / VolumeConv.CentiMetersCubic.Multiplicator;
|
init => _Value = value._Value / VolumeConv.CentiMetersCubic.Multiplicator;
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
public static ForceVolumetric KiloNewtonPerMeterCubic { get; } = new() { PerMeterCubic = new() { KiloNewtons = 1 } };
|
public static ForceVolumetric KiloNewtonPerMeterCubic { get; } = new() { PerMeterCubic = new() { KiloNewtons = 1 } };
|
||||||
public static ForceVolumetric TonForcePerMeterCubic { get; } = new() { PerMeterCubic = new() { TonForces = 1 } };
|
public static ForceVolumetric TonForcePerMeterCubic { get; } = new() { PerMeterCubic = new() { TonForces = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Force PerMeterCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Force PerMeterCubic
|
||||||
{
|
{
|
||||||
get => new(_Value * VolumeConv.MetersCubic.Multiplicator);
|
get => new(_Value * VolumeConv.MetersCubic.Multiplicator);
|
||||||
init => _Value = value._Value / VolumeConv.MetersCubic.Multiplicator;
|
init => _Value = value._Value / VolumeConv.MetersCubic.Multiplicator;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
public static MassLinear KiloGramPerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloGrams = 1 } };
|
public static MassLinear KiloGramPerMilliMeter { get; } = new() { _PerMilliMeter = new() { KiloGrams = 1 } };
|
||||||
public static MassLinear CentnerPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Centners = 1 } };
|
public static MassLinear CentnerPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Centners = 1 } };
|
||||||
public static MassLinear TonPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Tons = 1 } };
|
public static MassLinear TonPerMilliMeter { get; } = new() { _PerMilliMeter = new() { Tons = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Mass _PerMilliMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass _PerMilliMeter
|
||||||
{ get => (Mass)_Value; init => _Value = (double)value; }
|
{ get => (Mass)_Value; init => _Value = (double)value; }
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
public static MassLinear KiloGramPerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloGrams = 1 } };
|
public static MassLinear KiloGramPerCentiMeter { get; } = new() { PerCentiMeter = new() { KiloGrams = 1 } };
|
||||||
public static MassLinear CentnerPerCentiMeter { get; } = new() { PerCentiMeter = new() { Centners = 1 } };
|
public static MassLinear CentnerPerCentiMeter { get; } = new() { PerCentiMeter = new() { Centners = 1 } };
|
||||||
public static MassLinear TonPerCentiMeter { get; } = new() { PerCentiMeter = new() { Tons = 1 } };
|
public static MassLinear TonPerCentiMeter { get; } = new() { PerCentiMeter = new() { Tons = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Mass PerCentiMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass PerCentiMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.CentiMeters.Multiplicator);
|
get => new(_Value * LengthConv.CentiMeters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.CentiMeters.Multiplicator;
|
init => _Value = value._Value / LengthConv.CentiMeters.Multiplicator;
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
public static MassLinear CentnerPerDeciMeter { get; } = new() { PerDeciMeter = new() { Centners = 1 } };
|
public static MassLinear CentnerPerDeciMeter { get; } = new() { PerDeciMeter = new() { Centners = 1 } };
|
||||||
public static MassLinear TonPerDeciMeter { get; } = new() { PerDeciMeter = new() { Tons = 1 } };
|
public static MassLinear TonPerDeciMeter { get; } = new() { PerDeciMeter = new() { Tons = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Mass PerDeciMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass PerDeciMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.DeciMeters.Multiplicator);
|
get => new(_Value * LengthConv.DeciMeters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.DeciMeters.Multiplicator;
|
init => _Value = value._Value / LengthConv.DeciMeters.Multiplicator;
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
public static MassLinear CentnerPerMeter { get; } = new() { PerMeter = new() { Centners = 1 } };
|
public static MassLinear CentnerPerMeter { get; } = new() { PerMeter = new() { Centners = 1 } };
|
||||||
public static MassLinear TonPerMeter { get; } = new() { PerMeter = new() { Tons = 1 } };
|
public static MassLinear TonPerMeter { get; } = new() { PerMeter = new() { Tons = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Mass PerMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass PerMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.Meters.Multiplicator);
|
get => new(_Value * LengthConv.Meters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.Meters.Multiplicator;
|
init => _Value = value._Value / LengthConv.Meters.Multiplicator;
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
public static MassLinear CentnerPerKiloMeter { get; } = new() { PerKiloMeter = new() { Centners = 1 } };
|
public static MassLinear CentnerPerKiloMeter { get; } = new() { PerKiloMeter = new() { Centners = 1 } };
|
||||||
public static MassLinear TonPerKiloMeter { get; } = new() { PerKiloMeter = new() { Tons = 1 } };
|
public static MassLinear TonPerKiloMeter { get; } = new() { PerKiloMeter = new() { Tons = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Mass PerKiloMeter
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass PerKiloMeter
|
||||||
{
|
{
|
||||||
get => new(_Value * LengthConv.KiloMeters.Multiplicator);
|
get => new(_Value * LengthConv.KiloMeters.Multiplicator);
|
||||||
init => _Value = value._Value / LengthConv.KiloMeters.Multiplicator;
|
init => _Value = value._Value / LengthConv.KiloMeters.Multiplicator;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
public static Density KiloGramPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { KiloGrams = 1 } };
|
public static Density KiloGramPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { KiloGrams = 1 } };
|
||||||
public static Density CentnerPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { Centners = 1 } };
|
public static Density CentnerPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { Centners = 1 } };
|
||||||
public static Density TonPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { Tons = 1 } };
|
public static Density TonPerMilliMeterCubic { get; } = new() { _PerMilliMeterCubic = new() { Tons = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Mass _PerMilliMeterCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass _PerMilliMeterCubic
|
||||||
{ get => (Mass)_Value; init => _Value = (double)value; }
|
{ get => (Mass)_Value; init => _Value = (double)value; }
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
public static Density KiloGramPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { KiloGrams = 1 } };
|
public static Density KiloGramPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { KiloGrams = 1 } };
|
||||||
public static Density CentnerPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { Centners = 1 } };
|
public static Density CentnerPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { Centners = 1 } };
|
||||||
public static Density TonPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { Tons = 1 } };
|
public static Density TonPerCentiMeterCubic { get; } = new() { PerCentiMeterCubic = new() { Tons = 1 } };
|
||||||
[NotMapped, JsonIgnore] public Mass PerCentiMeterCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass PerCentiMeterCubic
|
||||||
{
|
{
|
||||||
get => new(_Value * VolumeConv.CentiMetersCubic.Multiplicator);
|
get => new(_Value * VolumeConv.CentiMetersCubic.Multiplicator);
|
||||||
init => _Value = value._Value / VolumeConv.CentiMetersCubic.Multiplicator;
|
init => _Value = value._Value / VolumeConv.CentiMetersCubic.Multiplicator;
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
public static Density CentnerPerMeterCubic { get; } = new() { PerMeterCubic = new() { Centners = 1 } };
|
public static Density CentnerPerMeterCubic { get; } = new() { PerMeterCubic = new() { Centners = 1 } };
|
||||||
public static Density TonPerMeterCubic { get; } = new() { PerMeterCubic = new() { Tons = 1 } };
|
public static Density TonPerMeterCubic { get; } = new() { PerMeterCubic = new() { Tons = 1 } };
|
||||||
|
|
||||||
[NotMapped, JsonIgnore] public Mass PerMeterCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public Mass PerMeterCubic
|
||||||
{
|
{
|
||||||
get => new(_Value * VolumeConv.MetersCubic.Multiplicator);
|
get => new(_Value * VolumeConv.MetersCubic.Multiplicator);
|
||||||
init => _Value = value._Value / VolumeConv.MetersCubic.Multiplicator;
|
init => _Value = value._Value / VolumeConv.MetersCubic.Multiplicator;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Force
|
public readonly partial record struct Force
|
||||||
{
|
{
|
||||||
public static Force _Newton { get; } = new() { _Newtons = 1 };
|
public static Force _Newton { get; } = new() { _Newtons = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _Newtons { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _Newtons { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Force KiloGramForce { get; } = new() { KiloGramForces = 1 };
|
public static Force KiloGramForce { get; } = new() { KiloGramForces = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloGramForces
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloGramForces
|
||||||
{
|
{
|
||||||
get => ForceConv.KiloGramForces.From(_Value);
|
get => ForceConv.KiloGramForces.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Force
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Force KiloNewton { get; } = new() { KiloNewtons = 1 };
|
public static Force KiloNewton { get; } = new() { KiloNewtons = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloNewtons
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloNewtons
|
||||||
{
|
{
|
||||||
get => ForceConv.KiloNewtons.From(_Value);
|
get => ForceConv.KiloNewtons.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -31,7 +31,7 @@ public readonly partial record struct Force
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Force TonForce { get; } = new() { TonForces = 1 };
|
public static Force TonForce { get; } = new() { TonForces = 1 };
|
||||||
[NotMapped, JsonIgnore] public double TonForces
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double TonForces
|
||||||
{
|
{
|
||||||
get => ForceConv.TonForces.From(_Value);
|
get => ForceConv.TonForces.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Frequency
|
public readonly partial record struct Frequency
|
||||||
{
|
{
|
||||||
public static Frequency _OneHertz { get; } = new() { _Hertz = 1 };
|
public static Frequency _OneHertz { get; } = new() { _Hertz = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _Hertz { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _Hertz { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Frequency OneKiloHertz { get; } = new() { KiloHertz = 1 };
|
public static Frequency OneKiloHertz { get; } = new() { KiloHertz = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloHertz
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloHertz
|
||||||
{
|
{
|
||||||
get => FrequencyConv.KiloHertz.From(_Value);
|
get => FrequencyConv.KiloHertz.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Frequency
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Frequency OneMegaHertz { get; } = new() { MegaHertz = 1 };
|
public static Frequency OneMegaHertz { get; } = new() { MegaHertz = 1 };
|
||||||
[NotMapped, JsonIgnore] public double MegaHertz
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double MegaHertz
|
||||||
{
|
{
|
||||||
get => FrequencyConv.MegaHertz.From(_Value);
|
get => FrequencyConv.MegaHertz.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Length
|
public readonly partial record struct Length
|
||||||
{
|
{
|
||||||
public static Length _MilliMeter { get; } = new(1);
|
public static Length _MilliMeter { get; } = new(1);
|
||||||
[NotMapped, JsonIgnore] public double _MilliMeters { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMeters { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Length CentiMeter { get; } = new(LengthConv.CentiMeters.To(1));
|
public static Length CentiMeter { get; } = new(LengthConv.CentiMeters.To(1));
|
||||||
[NotMapped, JsonIgnore]
|
[NotMapped, JsonIgnore, IgnoreDataMember]
|
||||||
public double CentiMeters
|
public double CentiMeters
|
||||||
{
|
{
|
||||||
get => LengthConv.CentiMeters.From(_Value);
|
get => LengthConv.CentiMeters.From(_Value);
|
||||||
@@ -19,7 +19,7 @@ public readonly partial record struct Length
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Length DeciMeter { get; } = new(LengthConv.DeciMeters.To(1));
|
public static Length DeciMeter { get; } = new(LengthConv.DeciMeters.To(1));
|
||||||
[NotMapped, JsonIgnore]
|
[NotMapped, JsonIgnore, IgnoreDataMember]
|
||||||
public double DeciMeters
|
public double DeciMeters
|
||||||
{
|
{
|
||||||
get => LengthConv.DeciMeters.From(_Value);
|
get => LengthConv.DeciMeters.From(_Value);
|
||||||
@@ -27,7 +27,7 @@ public readonly partial record struct Length
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Length Meter { get; } = new(LengthConv.Meters.To(1));
|
public static Length Meter { get; } = new(LengthConv.Meters.To(1));
|
||||||
[NotMapped, JsonIgnore]
|
[NotMapped, JsonIgnore, IgnoreDataMember]
|
||||||
public double Meters
|
public double Meters
|
||||||
{
|
{
|
||||||
get => LengthConv.Meters.From(_Value);
|
get => LengthConv.Meters.From(_Value);
|
||||||
@@ -35,7 +35,7 @@ public readonly partial record struct Length
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Length KiloMeter { get; } = new(LengthConv.KiloMeters.To(1));
|
public static Length KiloMeter { get; } = new(LengthConv.KiloMeters.To(1));
|
||||||
[NotMapped, JsonIgnore]
|
[NotMapped, JsonIgnore, IgnoreDataMember]
|
||||||
public double KiloMeters
|
public double KiloMeters
|
||||||
{
|
{
|
||||||
get => LengthConv.KiloMeters.From(_Value);
|
get => LengthConv.KiloMeters.From(_Value);
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Mass
|
public readonly partial record struct Mass
|
||||||
{
|
{
|
||||||
public static Mass _Gram { get; } = new() { _Grams = 1 };
|
public static Mass _Gram { get; } = new() { _Grams = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _Grams { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _Grams { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Mass KiloGram { get; } = new() { KiloGrams = 1 };
|
public static Mass KiloGram { get; } = new() { KiloGrams = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloGrams
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloGrams
|
||||||
{
|
{
|
||||||
get => MassConv.KiloGrams.From(_Value);
|
get => MassConv.KiloGrams.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -20,7 +20,7 @@ public readonly partial record struct Mass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static Mass Centner { get; } = new() { Centners = 1 };
|
public static Mass Centner { get; } = new() { Centners = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Centners
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Centners
|
||||||
{
|
{
|
||||||
get => MassConv.Centners.From(_Value);
|
get => MassConv.Centners.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -30,7 +30,7 @@ public readonly partial record struct Mass
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Mass Ton { get; } = new() { Tons = 1 };
|
public static Mass Ton { get; } = new() { Tons = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Tons
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Tons
|
||||||
{
|
{
|
||||||
get => MassConv.Tons.From(_Value);
|
get => MassConv.Tons.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct MassPerSquare
|
public readonly partial record struct MassPerSquare
|
||||||
{
|
{
|
||||||
public static MassPerSquare _KiloGramPerMeterSquared { get; } = new() { _KiloGramsPerMeterSquared = 1 };
|
public static MassPerSquare _KiloGramPerMeterSquared { get; } = new() { _KiloGramsPerMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _KiloGramsPerMeterSquared { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _KiloGramsPerMeterSquared { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static MassPerSquare KiloGramPerMilliMeterSquared { get; } = new() { KiloGramsPerMilliMeterSquared = 1 };
|
public static MassPerSquare KiloGramPerMilliMeterSquared { get; } = new() { KiloGramsPerMilliMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloGramsPerMilliMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloGramsPerMilliMeterSquared
|
||||||
{
|
{
|
||||||
get => MassPerSquareConv.KiloGramsPerMilliMeterSquared.From(_Value);
|
get => MassPerSquareConv.KiloGramsPerMilliMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Pressure
|
public readonly partial record struct Pressure
|
||||||
{
|
{
|
||||||
public static Pressure _Pascal { get; } = new() { _Pascals = 1 };
|
public static Pressure _Pascal { get; } = new() { _Pascals = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _Pascals { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _Pascals { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Pressure NewtonPerMeterSquared { get; } = new() { NewtonsPerMeterSquared = 1 };
|
public static Pressure NewtonPerMeterSquared { get; } = new() { NewtonsPerMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double NewtonsPerMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double NewtonsPerMeterSquared
|
||||||
{
|
{
|
||||||
get => _Value;
|
get => _Value;
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure KiloPascal { get; } = new() { KiloPascals = 1 };
|
public static Pressure KiloPascal { get; } = new() { KiloPascals = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloPascals
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloPascals
|
||||||
{
|
{
|
||||||
get => PressureConv.KiloPascals.From(_Value);
|
get => PressureConv.KiloPascals.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -31,7 +31,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure MegaPascal { get; } = new() { MegaPascals = 1 };
|
public static Pressure MegaPascal { get; } = new() { MegaPascals = 1 };
|
||||||
[NotMapped, JsonIgnore] public double MegaPascals
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double MegaPascals
|
||||||
{
|
{
|
||||||
get => PressureConv.MegaPascals.From(_Value);
|
get => PressureConv.MegaPascals.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -41,7 +41,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure NewtonPerMilliMeterSquared { get; } = new() { NewtonsPerMilliMeterSquared = 1 };
|
public static Pressure NewtonPerMilliMeterSquared { get; } = new() { NewtonsPerMilliMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double NewtonsPerMilliMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double NewtonsPerMilliMeterSquared
|
||||||
{
|
{
|
||||||
get => PressureConv.NewtonsPerMilliMeterSquared.From(_Value);
|
get => PressureConv.NewtonsPerMilliMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -51,7 +51,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure KiloGramForcePerMilliMeterSquared { get; } = new() { KiloGramForcesPerMilliMeterSquared = 1 };
|
public static Pressure KiloGramForcePerMilliMeterSquared { get; } = new() { KiloGramForcesPerMilliMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloGramForcesPerMilliMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloGramForcesPerMilliMeterSquared
|
||||||
{
|
{
|
||||||
get => PressureConv.KiloGramForcesPerMilliMeterSquared.From(_Value);
|
get => PressureConv.KiloGramForcesPerMilliMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -61,7 +61,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure KiloGramForcePerMeterSquared { get; } = new() { KiloGramForcesPerMeterSquared = 1 };
|
public static Pressure KiloGramForcePerMeterSquared { get; } = new() { KiloGramForcesPerMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloGramForcesPerMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloGramForcesPerMeterSquared
|
||||||
{
|
{
|
||||||
get => PressureConv.KiloGramForcesPerMeterSquared.From(_Value);
|
get => PressureConv.KiloGramForcesPerMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -71,7 +71,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure KiloNewtonPerMilliMeterSquared { get; } = new() { KiloNewtonsPerMilliMeterSquared = 1 };
|
public static Pressure KiloNewtonPerMilliMeterSquared { get; } = new() { KiloNewtonsPerMilliMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloNewtonsPerMilliMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloNewtonsPerMilliMeterSquared
|
||||||
{
|
{
|
||||||
get => PressureConv.KiloNewtonsPerMilliMeterSquared.From(_Value);
|
get => PressureConv.KiloNewtonsPerMilliMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -81,7 +81,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure KiloNewtonPerMeterSquared { get; } = new() { KiloNewtonsPerMeterSquared = 1 };
|
public static Pressure KiloNewtonPerMeterSquared { get; } = new() { KiloNewtonsPerMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloNewtonsPerMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloNewtonsPerMeterSquared
|
||||||
{
|
{
|
||||||
get => PressureConv.KiloNewtonsPerMeterSquared.From(_Value);
|
get => PressureConv.KiloNewtonsPerMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -91,7 +91,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure TonForcePerMilliMeterSquared { get; } = new() { TonForcesPerMilliMeterSquared = 1 };
|
public static Pressure TonForcePerMilliMeterSquared { get; } = new() { TonForcesPerMilliMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double TonForcesPerMilliMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double TonForcesPerMilliMeterSquared
|
||||||
{
|
{
|
||||||
get => PressureConv.TonForcesPerMilliMeterSquared.From(_Value);
|
get => PressureConv.TonForcesPerMilliMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -101,7 +101,7 @@ public readonly partial record struct Pressure
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pressure TonForcePerMeterSquared { get; } = new() { TonForcesPerMeterSquared = 1 };
|
public static Pressure TonForcePerMeterSquared { get; } = new() { TonForcesPerMeterSquared = 1 };
|
||||||
[NotMapped, JsonIgnore] public double TonForcesPerMeterSquared
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double TonForcesPerMeterSquared
|
||||||
{
|
{
|
||||||
get => PressureConv.TonForcesPerMeterSquared.From(_Value);
|
get => PressureConv.TonForcesPerMeterSquared.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Speed
|
public readonly partial record struct Speed
|
||||||
{
|
{
|
||||||
public static Speed _KiloMeterPerHour { get; } = new() { _KiloMetersPerHour = 1 };
|
public static Speed _KiloMeterPerHour { get; } = new() { _KiloMetersPerHour = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _KiloMetersPerHour { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _KiloMetersPerHour { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Speed MeterPerSecond { get; } = new() { MetersPerSecond = 1 };
|
public static Speed MeterPerSecond { get; } = new() { MetersPerSecond = 1 };
|
||||||
[NotMapped, JsonIgnore] public double MetersPerSecond
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double MetersPerSecond
|
||||||
{
|
{
|
||||||
get => SpeedConv.MetersPerSecond.From(_Value);
|
get => SpeedConv.MetersPerSecond.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Time
|
public readonly partial record struct Time
|
||||||
{
|
{
|
||||||
public static Time _MilliSecond { get; } = new() { _MilliSeconds = 1 };
|
public static Time _MilliSecond { get; } = new() { _MilliSeconds = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _MilliSeconds { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliSeconds { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Time Second { get; } = new() { Seconds = 1 };
|
public static Time Second { get; } = new() { Seconds = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Seconds
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Seconds
|
||||||
{
|
{
|
||||||
get => TimeConv.Seconds.From(_Value);
|
get => TimeConv.Seconds.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Time
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Time Minute { get; } = new() { Minutes = 1 };
|
public static Time Minute { get; } = new() { Minutes = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Minutes
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Minutes
|
||||||
{
|
{
|
||||||
get => TimeConv.Minutes.From(_Value);
|
get => TimeConv.Minutes.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -31,7 +31,7 @@ public readonly partial record struct Time
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Time Hour { get; } = new() { Hours = 1 };
|
public static Time Hour { get; } = new() { Hours = 1 };
|
||||||
[NotMapped, JsonIgnore] public double Hours
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Hours
|
||||||
{
|
{
|
||||||
get => TimeConv.Hours.From(_Value);
|
get => TimeConv.Hours.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Torque
|
public readonly partial record struct Torque
|
||||||
{
|
{
|
||||||
public static Torque _Newton_Meter { get; } = new() { _Newton_Meters = 1 };
|
public static Torque _Newton_Meter { get; } = new() { _Newton_Meters = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _Newton_Meters { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _Newton_Meters { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Torque KiloGramForce_Meter { get; } = new() { KiloGramForce_Meters = 1 };
|
public static Torque KiloGramForce_Meter { get; } = new() { KiloGramForce_Meters = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloGramForce_Meters
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloGramForce_Meters
|
||||||
{
|
{
|
||||||
get => TorqueConv.KiloGramForce_Meters.From(_Value);
|
get => TorqueConv.KiloGramForce_Meters.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Torque
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Torque TonnForce_Meter { get; } = new() { TonnForce_Meters = 1 };
|
public static Torque TonnForce_Meter { get; } = new() { TonnForce_Meters = 1 };
|
||||||
[NotMapped, JsonIgnore] public double TonnForce_Meters
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double TonnForce_Meters
|
||||||
{
|
{
|
||||||
get => TorqueConv.TonnForce_Meters.From(_Value);
|
get => TorqueConv.TonnForce_Meters.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Voltage
|
public readonly partial record struct Voltage
|
||||||
{
|
{
|
||||||
public static Voltage _Volt { get; } = new() { _Volts = 1 };
|
public static Voltage _Volt { get; } = new() { _Volts = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _Volts { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _Volts { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Voltage KiloVolt { get; } = new() { KiloVolts = 1 };
|
public static Voltage KiloVolt { get; } = new() { KiloVolts = 1 };
|
||||||
[NotMapped, JsonIgnore] public double KiloVolts
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloVolts
|
||||||
{
|
{
|
||||||
get => VoltageConv.KiloVolts.From(_Value);
|
get => VoltageConv.KiloVolts.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Voltage
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Voltage MegaVolt { get; } = new() { MegaVolts = 1 };
|
public static Voltage MegaVolt { get; } = new() { MegaVolts = 1 };
|
||||||
[NotMapped, JsonIgnore] public double MegaVolts
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double MegaVolts
|
||||||
{
|
{
|
||||||
get => VoltageConv.MegaVolts.From(_Value);
|
get => VoltageConv.MegaVolts.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
public readonly partial record struct Volume
|
public readonly partial record struct Volume
|
||||||
{
|
{
|
||||||
public static Volume _MilliMeterCubic { get; } = new() { _MilliMetersCubic = 1 };
|
public static Volume _MilliMeterCubic { get; } = new() { _MilliMetersCubic = 1 };
|
||||||
[NotMapped, JsonIgnore] public double _MilliMetersCubic { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMetersCubic { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static Volume CentiMeterCubic { get; } = new() { CentiMetersCubic = 1 };
|
public static Volume CentiMeterCubic { get; } = new() { CentiMetersCubic = 1 };
|
||||||
[NotMapped, JsonIgnore] public double CentiMetersCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double CentiMetersCubic
|
||||||
{
|
{
|
||||||
get => VolumeConv.CentiMetersCubic.From(_Value);
|
get => VolumeConv.CentiMetersCubic.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -21,7 +21,7 @@ public readonly partial record struct Volume
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Volume MeterCubic { get; } = new() { MetersCubic = 1 };
|
public static Volume MeterCubic { get; } = new() { MetersCubic = 1 };
|
||||||
[NotMapped, JsonIgnore] public double MetersCubic
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double MetersCubic
|
||||||
{
|
{
|
||||||
get => VolumeConv.MetersCubic.From(_Value);
|
get => VolumeConv.MetersCubic.From(_Value);
|
||||||
init
|
init
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ namespace QWERTYkez.Mensura.Units;
|
|||||||
public readonly partial record struct XXXXXXXXXXXXXX
|
public readonly partial record struct XXXXXXXXXXXXXX
|
||||||
{
|
{
|
||||||
public static XXXXXXXXXXXXXX MilliMeter { get; } = new(1);
|
public static XXXXXXXXXXXXXX MilliMeter { get; } = new(1);
|
||||||
[NotMapped, JsonIgnore] public double _MilliMeters { get => _Value; init => _Value = value; }
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMeters { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX CentiMeter { get; } = new(XXXXXXXXXXXXXXConv.CentiMeters.To(1));
|
public static XXXXXXXXXXXXXX CentiMeter { get; } = new(XXXXXXXXXXXXXXConv.CentiMeters.To(1));
|
||||||
[NotMapped, JsonIgnore] public double CentiMeters
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double CentiMeters
|
||||||
{
|
{
|
||||||
get => XXXXXXXXXXXXXXConv.CentiMeters.From(_Value);
|
get => XXXXXXXXXXXXXXConv.CentiMeters.From(_Value);
|
||||||
init
|
init
|
||||||
@@ -30,21 +30,21 @@ public readonly partial record struct XXXXXXXXXXXXXX
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX DeciMeter { get; } = new(XXXXXXXXXXXXXXConv.DeciMeters.To(1));
|
public static XXXXXXXXXXXXXX DeciMeter { get; } = new(XXXXXXXXXXXXXXConv.DeciMeters.To(1));
|
||||||
[NotMapped, JsonIgnore] public double DeciMeters
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double DeciMeters
|
||||||
{
|
{
|
||||||
get => XXXXXXXXXXXXXXConv.DeciMeters.From(_Value);
|
get => XXXXXXXXXXXXXXConv.DeciMeters.From(_Value);
|
||||||
init => _Value = XXXXXXXXXXXXXXConv.DeciMeters.To(value);
|
init => _Value = XXXXXXXXXXXXXXConv.DeciMeters.To(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX Meter { get; } = new(XXXXXXXXXXXXXXConv.Meters.To(1));
|
public static XXXXXXXXXXXXXX Meter { get; } = new(XXXXXXXXXXXXXXConv.Meters.To(1));
|
||||||
[NotMapped, JsonIgnore] public double Meters
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double Meters
|
||||||
{
|
{
|
||||||
get => XXXXXXXXXXXXXXConv.Meters.From(_Value);
|
get => XXXXXXXXXXXXXXConv.Meters.From(_Value);
|
||||||
init => _Value = XXXXXXXXXXXXXXConv.Meters.To(value);
|
init => _Value = XXXXXXXXXXXXXXConv.Meters.To(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX KiloMeter { get; } = new(XXXXXXXXXXXXXXConv.KiloMeters.To(1));
|
public static XXXXXXXXXXXXXX KiloMeter { get; } = new(XXXXXXXXXXXXXXConv.KiloMeters.To(1));
|
||||||
[NotMapped, JsonIgnore] public double KiloMeters
|
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloMeters
|
||||||
{
|
{
|
||||||
get => XXXXXXXXXXXXXXConv.KiloMeters.From(_Value);
|
get => XXXXXXXXXXXXXXConv.KiloMeters.From(_Value);
|
||||||
init => _Value = XXXXXXXXXXXXXXConv.KiloMeters.To(value);
|
init => _Value = XXXXXXXXXXXXXXConv.KiloMeters.To(value);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ global using System.Diagnostics;
|
|||||||
global using System.Numerics;
|
global using System.Numerics;
|
||||||
global using System.Runtime.CompilerServices;
|
global using System.Runtime.CompilerServices;
|
||||||
global using System.Runtime.InteropServices;
|
global using System.Runtime.InteropServices;
|
||||||
|
global using System.Runtime.Serialization;
|
||||||
global using System.Text.Json;
|
global using System.Text.Json;
|
||||||
global using System.Text.Json.Serialization;
|
global using System.Text.Json.Serialization;
|
||||||
global using QWERTYkez.Mensura;
|
global using QWERTYkez.Mensura;
|
||||||
|
|||||||
Reference in New Issue
Block a user