[NUI] Fix Build warnings: override Equals and GetHashCode 30/150230/3
authorhuiyu,eun <huiyu.eun@samsung.com>
Fri, 15 Sep 2017 01:30:44 +0000 (10:30 +0900)
committerhuiyu,eun <huiyu.eun@samsung.com>
Thu, 21 Sep 2017 01:33:47 +0000 (10:33 +0900)
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 <huiyu.eun@samsung.com>
src/Tizen.NUI/src/public/BaseHandle.cs
src/Tizen.NUI/src/public/PaddingType.cs
src/Tizen.NUI/src/public/Rectangle.cs

index 40ed2a1..8857779 100755 (executable)
@@ -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())
         {
index b0e3019..f5b11af 100755 (executable)
@@ -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
         {
index 0452847..e408d55 100755 (executable)
@@ -124,7 +124,37 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// The Inequality operator.
+        /// Equality operator.
+        /// </summary>
+        /// <param name="o">The object to compare with the current object.</param>
+        /// <returns>True if boxes are exactly same.</returns>
+        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;
+        }
+
+        /// <summary>
+        /// Serves as the default hash function.
+        /// </summary>
+        /// <returns>A hash code for the current object.</returns>
+        public override int GetHashCode()
+        {
+            return base.GetHashCode();
+        }
+
+        /// <summary>
+        /// Inequality operator.
         /// </summary>
         /// <param name="a">The first rectangle.</param>
         /// <param name="b">The second rectangle.</param>