FastEqualsCheck() private method

private FastEqualsCheck ( Object a, Object b ) : bool
a Object
b Object
return bool
Example #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            RuntimeType runtimeType = (RuntimeType)this.GetType();

            if ((RuntimeType)obj.GetType() != runtimeType)
            {
                return(false);
            }
            object a = (object)this;

            if (ValueType.CanCompareBits((object)this))
            {
                return(ValueType.FastEqualsCheck(a, obj));
            }
            FieldInfo[] fields = runtimeType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            for (int index = 0; index < fields.Length; ++index)
            {
                object obj1 = ((RtFieldInfo)fields[index]).UnsafeGetValue(a);
                object obj2 = ((RtFieldInfo)fields[index]).UnsafeGetValue(obj);
                if (obj1 == null)
                {
                    if (obj2 != null)
                    {
                        return(false);
                    }
                }
                else if (!obj1.Equals(obj2))
                {
                    return(false);
                }
            }
            return(true);
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            RuntimeType runtimeType = (RuntimeType)base.GetType();
            RuntimeType left        = (RuntimeType)obj.GetType();

            if (left != runtimeType)
            {
                return(false);
            }
            if (ValueType.CanCompareBits(this))
            {
                return(ValueType.FastEqualsCheck(this, obj));
            }
            FieldInfo[] fields = runtimeType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            for (int i = 0; i < fields.Length; i++)
            {
                object obj2 = ((RtFieldInfo)fields[i]).UnsafeGetValue(this);
                object obj3 = ((RtFieldInfo)fields[i]).UnsafeGetValue(obj);
                if (obj2 == null)
                {
                    if (obj3 != null)
                    {
                        return(false);
                    }
                }
                else if (!obj2.Equals(obj3))
                {
                    return(false);
                }
            }
            return(true);
        }