diff --git a/src/bindings/mono/eina_mono/eina_error.cs b/src/bindings/mono/eina_mono/eina_error.cs index 5c4ac9345b..c936b88179 100644 --- a/src/bindings/mono/eina_mono/eina_error.cs +++ b/src/bindings/mono/eina_mono/eina_error.cs @@ -24,7 +24,7 @@ namespace Eina /// Error codes from native Eina methods. /// Since EFL 1.23. /// -public struct Error : IComparable +public struct Error : IComparable, IEquatable { int code; @@ -94,17 +94,6 @@ public struct Error : IComparable return error.code; } - /// - /// Compare two Errors. - /// Since EFL 1.23. - /// - /// Error to be compared with - /// True with the Errors is equal, False otherwise. - public int CompareTo(Error err) - { - return code.CompareTo(err.code); - } - /// /// Transform the object to a string representing the object. /// Since EFL 1.23. @@ -197,6 +186,98 @@ public struct Error : IComparable { return eina_error_msg_register(msg); } -} + + /// + /// Gets a hash for . + /// Since EFL 1.23. + /// + /// A hash code. + public override int GetHashCode() + => code.GetHashCode() + Message.GetHashCode(); + + /// + /// Compare to a given error. + /// Since EFL 1.23. + /// + /// Error to be compared with. + /// -1, 0 or 1 if -1 if Error is less, equal or greater than err. + public int CompareTo(Error err) => code.CompareTo(err.code); + + /// + /// Check if is equal to obj. + /// Since EFL 1.23. + /// + /// The object to be checked. + /// false if obj is null or not equals, true otherwise. + public override bool Equals(object obj) + { + if (object.ReferenceEquals(obj, null)) + return false; + + return this.Equals((Error)obj); + } + + /// + /// Check if is equal to err. + /// Since EFL 1.23. + /// + /// The object to be checked. + /// false if obj is null or not equals, true otherwise. + public bool Equals(Error err) => this.CompareTo(err) == 0; + + /// + /// Check if lhs is equals to rhs. + /// Since EFL 1.23. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equals to rhs, false otherwise. + public static bool operator==(Error lhs, Error rhs) => lhs.Equals(rhs); + + /// + /// Check if lhs is not equals to rhs. + /// Since EFL 1.23. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equals to rhs, false otherwise. + public static bool operator!=(Error lhs, Error rhs) => !(lhs == rhs); + + /// + /// Check if lhs is less than rhs. + /// Since EFL 1.23. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is less than rhs, false otherwise. + public static bool operator<(Error lhs, Error rhs) => (lhs.CompareTo(rhs) < 0); + + /// + /// Check if lhs is greater to rhs. + /// Since EFL 1.23. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is greater than rhs, false otherwise. + public static bool operator>(Error lhs, Error rhs) => rhs < lhs; + + /// + /// Check if lhs is equals and less than rhs. + /// Since EFL 1.23. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equals and less than rhs, false otherwise. + public static bool operator<=(Error lhs, Error rhs) => !(lhs > rhs); + + /// + /// Check if lhs is equals and greater than rhs. + /// Since EFL 1.23. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equals and greater than rhs, false otherwise. + public static bool operator>=(Error lhs, Error rhs) => !(lhs < rhs); } +}