From: huiyu,eun Date: Fri, 15 Sep 2017 01:30:44 +0000 (+0900) Subject: [NUI] Fix Build warnings: override Equals and GetHashCode X-Git-Tag: preview1-00243~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F30%2F150230%2F3;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix Build warnings: override Equals and GetHashCode warings: CS0660, CS0661 CS0660: defines operator == or operator != but does not override Object.Equals(object o) CS0661: defines operator == or operator != but does not override Object.GetHashCode() please refer https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0660 https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0661 Change-Id: I2fc153fbf5490de9002ce0155e5c65e35f7e9d6e Signed-off-by: huiyu,eun --- diff --git a/src/Tizen.NUI/src/public/BaseHandle.cs b/src/Tizen.NUI/src/public/BaseHandle.cs index 40ed2a1..8857779 100755 --- a/src/Tizen.NUI/src/public/BaseHandle.cs +++ b/src/Tizen.NUI/src/public/BaseHandle.cs @@ -256,6 +256,41 @@ namespace Tizen.NUI return true; } + public override bool Equals(object o) + { + if(o == null) + { + return false; + } + if(!(o is BaseHandle)) + { + return false; + } + BaseHandle b = (BaseHandle)o; + if (!BaseHandle.ReferenceEquals(this, null) && !BaseHandle.ReferenceEquals(b, null)) + { + // drop into native code to see if both handles point to the same body + return this.IsEqual(b); + } + + if (BaseHandle.ReferenceEquals(this, null) && !BaseHandle.ReferenceEquals(b, null)) + { + if (b.HasBody()) return false; + else return true; + } + if (!BaseHandle.ReferenceEquals(this, null) && BaseHandle.ReferenceEquals(b, null)) + { + if (this.HasBody()) return false; + else return true; + } + + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } public BaseHandle() : this(NDalicPINVOKE.new_BaseHandle__SWIG_1()) { diff --git a/src/Tizen.NUI/src/public/PaddingType.cs b/src/Tizen.NUI/src/public/PaddingType.cs index b0e3019..f5b11af 100755 --- a/src/Tizen.NUI/src/public/PaddingType.cs +++ b/src/Tizen.NUI/src/public/PaddingType.cs @@ -125,6 +125,30 @@ namespace Tizen.NUI return !(a == b); } + public override bool Equals(object o) + { + if(o == null) + { + return false; + } + if(!(o is PaddingType)) + { + return false; + } + PaddingType p = (PaddingType)o; + + // Return true if the fields match: + return (System.Math.Abs(Left - p.Left) < NDalic.GetRangedEpsilon(Left, p.Left)) && + (System.Math.Abs(Right - p.Right) < NDalic.GetRangedEpsilon(Right, p.Right)) && + (System.Math.Abs(Bottom - p.Bottom) < NDalic.GetRangedEpsilon(Bottom, p.Bottom)) && + (System.Math.Abs(Top - p.Top) < NDalic.GetRangedEpsilon(Top, p.Top)); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + ///< The Left value public float Left { diff --git a/src/Tizen.NUI/src/public/Rectangle.cs b/src/Tizen.NUI/src/public/Rectangle.cs index 0452847..e408d55 100755 --- a/src/Tizen.NUI/src/public/Rectangle.cs +++ b/src/Tizen.NUI/src/public/Rectangle.cs @@ -124,7 +124,37 @@ namespace Tizen.NUI } /// - /// The Inequality operator. + /// Equality operator. + /// + /// The object to compare with the current object. + /// True if boxes are exactly same. + public override bool Equals(object o) + { + if(o == null) + { + return false; + } + if(!(o is Rectangle)) + { + return false; + } + Rectangle r = (Rectangle)o; + + // Return true if the fields match: + return X == r.X && Y == r.Y && Width == r.Width && Height == r.Height; + } + + /// + /// Serves as the default hash function. + /// + /// A hash code for the current object. + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Inequality operator. /// /// The first rectangle. /// The second rectangle.