IMensuraUnit<U>
All checks were successful
Publish NuGet packages / publish (push) Successful in 52s
All checks were successful
Publish NuGet packages / publish (push) Successful in 52s
This commit is contained in:
@@ -195,7 +195,7 @@ using System.Runtime.Serialization;
|
|||||||
namespace QWERTYkez.Mensura.Units;
|
namespace QWERTYkez.Mensura.Units;
|
||||||
|
|
||||||
[JsonConverter(typeof(UnitJsonConverter<{typeNameZ}>))]
|
[JsonConverter(typeof(UnitJsonConverter<{typeNameZ}>))]
|
||||||
public readonly partial record struct {typeNameZ} : IEquatable<{typeNameZ}>, IMensuraUnit
|
public readonly partial record struct {typeNameZ} : IEquatable<{typeNameZ}>, IMensuraUnit, IMensuraUnit<{typeNameZ}>
|
||||||
{
|
{
|
||||||
|
|
||||||
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
||||||
@@ -212,6 +212,16 @@ public readonly partial record struct {typeNameZ} : IEquatable<{typeNameZ}>, IMe
|
|||||||
public static explicit operator double({typeNameZ} unit) => unit._Value;
|
public static explicit operator double({typeNameZ} unit) => unit._Value;
|
||||||
|
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public {typeNameZ} 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);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ using System.Runtime.Serialization;
|
|||||||
namespace QWERTYkez.Mensura.Units;
|
namespace QWERTYkez.Mensura.Units;
|
||||||
|
|
||||||
[JsonConverter(typeof(UnitJsonConverter<{typeName}>))]
|
[JsonConverter(typeof(UnitJsonConverter<{typeName}>))]
|
||||||
public readonly partial record struct {typeName} : IEquatable<{typeName}>, IMensuraUnit
|
public readonly partial record struct {typeName} : IEquatable<{typeName}>, IMensuraUnit, IMensuraUnit<{typeName}>
|
||||||
{
|
{
|
||||||
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
||||||
internal double Value { get => _Value; init => _Value = value; }
|
internal double Value { get => _Value; init => _Value = value; }
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
namespace QWERTYkez.Mensura;
|
namespace QWERTYkez.Mensura;
|
||||||
|
|
||||||
public interface IMensuraUnit { }
|
public interface IMensuraUnit
|
||||||
|
{
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsPositive { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsNegative { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsZero { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsNaN { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsFinite { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsInfinity { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsPositiveInfinity { get; }
|
||||||
|
[JsonIgnore, IgnoreDataMember] public bool IsNegativeInfinity { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal interface IMensuraUnit<U> where U : struct, IMensuraUnit, IEquatable<U>
|
||||||
|
{
|
||||||
|
public U Abs();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user