Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 2 additions & 57 deletions UnitsNet/IArithmeticQuantity.cs
Original file line number Diff line number Diff line change
@@ -1,69 +1,14 @@
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.

#if NET
#if NET7_0_OR_GREATER
using System.Numerics;
#endif

namespace UnitsNet;

/// <summary>
/// Represents a quantity that has both magnitude and direction, supporting various arithmetic operations and
/// comparisons.
/// </summary>
/// <remarks>
/// This interface defines standard linear arithmetic operations such as addition, subtraction, multiplication, and
/// division.
/// These types of quantities naturally support comparison operations with either absolute or relative tolerance, which
/// is useful for determining equality within a certain margin of error.
/// <para>
/// For more information, see the Wikipedia page on
/// <a href="https://en.wikipedia.org/wiki/Dimensional_analysis#Geometry:_position_vs._displacement">
/// Dimensional
/// Analysis
/// </a>
/// .
/// </para>
/// </remarks>
/// <typeparam name="TSelf">The type that implements this interface.</typeparam>
public interface ILinearQuantity<TSelf> : IQuantityOfType<TSelf>, IArithmeticQuantity<TSelf>
#if NET7_0_OR_GREATER
, IAdditiveIdentity<TSelf, TSelf>
#endif
where TSelf : ILinearQuantity<TSelf>
{
#if NET7_0_OR_GREATER
/// <summary>
/// The zero value of this quantity.
/// </summary>
static abstract TSelf Zero { get; }

static TSelf IAdditiveIdentity<TSelf, TSelf>.AdditiveIdentity
{
get => TSelf.Zero;
}

#endif
}

/// <summary>
/// An <see cref="ILinearQuantity{TSelf}" /> with a strongly typed unit enum.
/// </summary>
/// <remarks>
/// This interface represents linear quantities with known unit enum types, and (in .NET 7+) implements generic math
/// interfaces for arithmetic operations.
/// </remarks>
/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>
/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>
public interface ILinearQuantity<TSelf, TUnitType> : IArithmeticQuantity<TSelf, TUnitType>, ILinearQuantity<TSelf>
where TSelf : ILinearQuantity<TSelf, TUnitType>
where TUnitType : struct, Enum
{
}

/// <summary>
/// An <see cref="IQuantity{TSelf, TUnitType}" /> that (in .NET 7+) implements generic math interfaces for arithmetic
/// operations.
/// A quantity that (in .NET 7+) implements generic math interfaces for arithmetic operations.
/// </summary>
/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>
/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>
Expand Down
62 changes: 62 additions & 0 deletions UnitsNet/ILinearQuantity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.

#if NET7_0_OR_GREATER
using System.Numerics;
#endif

namespace UnitsNet;

/// <summary>
/// An <see cref="ILinearQuantity{TSelf}" /> with a strongly typed unit enum.
/// </summary>
/// <remarks>
/// This interface represents linear quantities with known unit enum types, and (in .NET 7+) implements generic math
/// interfaces for arithmetic operations.
/// </remarks>
/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>
/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>
public interface ILinearQuantity<TSelf, TUnitType> : IArithmeticQuantity<TSelf, TUnitType>, ILinearQuantity<TSelf>
where TSelf : ILinearQuantity<TSelf, TUnitType>
where TUnitType : struct, Enum
{
}

/// <summary>
/// Represents a quantity that has both magnitude and direction, supporting various arithmetic operations and
/// comparisons.
/// </summary>
/// <remarks>
/// This interface defines standard linear arithmetic operations such as addition, subtraction, multiplication, and
/// division.
/// These types of quantities naturally support comparison operations with either absolute or relative tolerance, which
/// is useful for determining equality within a certain margin of error.
/// <para>
/// For more information, see the Wikipedia page on
/// <a href="https://en.wikipedia.org/wiki/Dimensional_analysis#Geometry:_position_vs._displacement">
/// Dimensional
/// Analysis
/// </a>
/// .
/// </para>
/// </remarks>
/// <typeparam name="TSelf">The type that implements this interface.</typeparam>
public interface ILinearQuantity<TSelf> : IQuantityOfType<TSelf>, IArithmeticQuantity<TSelf>
#if NET7_0_OR_GREATER
, IAdditiveIdentity<TSelf, TSelf>
#endif
where TSelf : ILinearQuantity<TSelf>
{
#if NET7_0_OR_GREATER
/// <summary>
/// The zero value of this quantity.
/// </summary>
static abstract TSelf Zero { get; }

static TSelf IAdditiveIdentity<TSelf, TSelf>.AdditiveIdentity
{
get => TSelf.Zero;
}

#endif
}
2 changes: 1 addition & 1 deletion UnitsNet/ILogarithmicQuantity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace UnitsNet;
/// <inheritdoc cref="ILogarithmicQuantity{TSelf}"/>
/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>
/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>
public interface ILogarithmicQuantity<TSelf, TUnitType> : IQuantity<TSelf, TUnitType>, ILogarithmicQuantity<TSelf>
public interface ILogarithmicQuantity<TSelf, TUnitType> : IArithmeticQuantity<TSelf, TUnitType>, ILogarithmicQuantity<TSelf>
where TSelf : ILogarithmicQuantity<TSelf, TUnitType>
where TUnitType : struct, Enum
{
Expand Down
Loading