using System; namespace Cobilas.Numeric { /// It represents the mathematical signal and performs its mathematical operation. public readonly struct MathOperator : IEquatable, IEquatable, IEquatable { private readonly string signal; private readonly byte executionLevel; private readonly SignalOrientation orientation; private readonly Func function; /// The sign of the mathematical operation. public string Signal => signal; /// The function that performs the mathematical operation. public Delegate Function => function; /// The order of execution of the mathematical operation. public byte ExecutionLevel => executionLevel; /// Indicates the direction where the operation numbers will be obtained. public SignalOrientation Orientation => orientation; /// The sign of the mathematical operation. /// The function that performs the mathematical operation. /// Indicates the direction where the operation numbers will be obtained. /// The order of execution of the mathematical operation. public MathOperator( string signal, Func function, SignalOrientation orientation, byte executionLevel) { this.signal = signal; this.function = function; this.orientation = orientation; this.executionLevel = executionLevel; } /// The sign of the mathematical operation. /// The function that performs the mathematical operation. /// Indicates the direction where the operation numbers will be obtained. public MathOperator( string signal, Func function, SignalOrientation orientation) : this(signal, function, orientation, 0) {} /// The sign of the mathematical operation. /// The function that performs the mathematical operation. /// Indicates the direction where the operation numbers will be obtained. /// The order of execution of the mathematical operation. public MathOperator( char signal, Func function, SignalOrientation orientation, byte executionLevel) : this(signal.ToString(), function, orientation, executionLevel) {} /// The sign of the mathematical operation. /// The function that performs the mathematical operation. /// Indicates the direction where the operation numbers will be obtained. public MathOperator( char signal, Func function, SignalOrientation orientation) : this(signal, function, orientation, 0) {} /// Performs the comparison between and . public bool Equals(string other) => other == signal; /// Performs the comparison between and . public bool Equals(byte other) => other == executionLevel; /// Performs the comparison between and . public bool Equals(SignalOrientation other) => other == orientation; /// Return the hash code for this instance. public override int GetHashCode() => base.GetHashCode(); /// Performs the comparison between and . public override bool Equals(object obj) => (obj is string str && Equals(str)) || (obj is byte bt && Equals(bt)) || (obj is SignalOrientation sot && Equals(sot)); #pragma warning disable CS1591 // O comentário XML ausente não foi encontrado para o tipo ou membro visível publicamente public static bool operator ==(string A, MathOperator B) => B.Equals(A); public static bool operator !=(string A, MathOperator B) => !B.Equals(A); public static bool operator ==(byte A, MathOperator B) => B.Equals(A); public static bool operator !=(byte A, MathOperator B) => !B.Equals(A); public static bool operator ==(SignalOrientation A, MathOperator B) => B.Equals(A); public static bool operator !=(SignalOrientation A, MathOperator B) => !B.Equals(A); public static bool operator ==(MathOperator A, string B) => A.Equals(B); public static bool operator !=(MathOperator A, string B) => !A.Equals(B); public static bool operator ==(MathOperator A, byte B) => A.Equals(B); public static bool operator !=(MathOperator A, byte B) => !A.Equals(B); public static bool operator ==(MathOperator A, SignalOrientation B) => A.Equals(B); public static bool operator !=(MathOperator A, SignalOrientation B) => !A.Equals(B); #pragma warning restore CS1591 // O comentário XML ausente não foi encontrado para o tipo ou membro visível publicamente } }