pogon...
This commit is contained in:
@@ -91,16 +91,21 @@ namespace QWERTYkez.Mensura
|
||||
// Вы должны скопировать сюда всё содержимое вашего второго файла,
|
||||
// заменив XXXXXXXXXXXXXX на {typeName}.
|
||||
string skeleton = @"
|
||||
global using {typeName} = QWERTYkez.Mensura.Units.{typeName};
|
||||
global using {typeName}Extensions = QWERTYkez.Mensura.Units.{typeName}Extensions;
|
||||
global using {typeName}Converter = QWERTYkez.Mensura.Units.{typeName}Converter;
|
||||
|
||||
using System.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace QWERTYkez.Mensura.Units;
|
||||
|
||||
[JsonConverter(typeof({typeName}Converter))]
|
||||
public readonly partial record struct {typeName}
|
||||
public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEquatable<{typeName}>, IMensuraUnit
|
||||
{
|
||||
[JsonInclude, DataMember, JsonPropertyName(""v"")] // для JSON / EF на случай сбоев, если пробелма с _Value
|
||||
internal double Value { get => _Value; init => _Value = value; }
|
||||
double IMensuraUnit.Value { get => _Value; init => _Value = value; }
|
||||
internal readonly double _Value;
|
||||
internal {typeName}(double value) => _Value = value;
|
||||
|
||||
@@ -113,8 +118,13 @@ public readonly partial record struct {typeName}
|
||||
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0;
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0;
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsNegative => _Value < 0;
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsNegative => double.IsNegative(_Value);
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsZero => _Value == 0;
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsNaN => double.IsNaN(_Value);
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsFinite => double.IsFinite(_Value);
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsInfinity => double.IsInfinity(_Value);
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsPositiveInfinity => double.IsPositiveInfinity(_Value);
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsNegativeInfinity => double.IsNegativeInfinity(_Value);
|
||||
|
||||
|
||||
public static {typeName} Zero { get; } = new(0d);
|
||||
@@ -298,7 +308,7 @@ public readonly partial record struct {typeName}
|
||||
}
|
||||
}
|
||||
|
||||
public static class {typeName}Extension
|
||||
public static class {typeName}Extensions
|
||||
{
|
||||
internal static double ToDouble(this {typeName}? unit) => unit is null ? 0d : unit.Value._Value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user