Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            RuntimeType type  = (RuntimeType)base.GetType();
            RuntimeType type2 = (RuntimeType)obj.GetType();

            if (type2 != type)
            {
                return(false);
            }
            object obj2 = this;

            FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < fields.Length; i++)
            {
                object obj3 = ((RuntimeFieldInfo)fields[i]).GetValue(obj2);
                object obj4 = ((RuntimeFieldInfo)fields[i]).GetValue(obj);
                if (obj3 == null)
                {
                    if (obj4 != null)
                    {
                        return(false);
                    }
                }
                else if (!obj3.Equals(obj4))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            RuntimeType thisType = (RuntimeType)this.GetType();
            RuntimeType thatType = (RuntimeType)obj.GetType();

            if (thatType != thisType)
            {
                return(false);
            }

            Object thisObj = this;
            Object thisResult, thatResult;

            FieldInfo[] thisFields = thisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            for (int i = 0; i < thisFields.Length; i++)
            {
                // Visibility check and consistency check are not necessary.
                thisResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(thisObj);
                thatResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(obj);

                if (!AreFieldValuesEqual(thisResult, thatResult))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
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 obj1 = (object)this;

            FieldInfo[] fields = runtimeType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            for (int index = 0; index < fields.Length; ++index)
            {
                object obj2 = fields[index].GetValue(obj1);
                object obj3 = fields[index].GetValue(obj);
                if (obj2 == null)
                {
                    if (obj3 != null)
                    {
                        return(false);
                    }
                }
                else if (!obj2.Equals(obj3))
                {
                    return(false);
                }
            }
            return(true);
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            RuntimeType type  = (RuntimeType)base.GetType();
            RuntimeType type2 = (RuntimeType)obj.GetType();

            if (type2 != type)
            {
                return(false);
            }
            object obj2 = this;

            FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < fields.Length; i++)
            {
                object thisValue = ((RtFieldInfo)fields[i]).InternalGetValue(obj2, false, false);
                object thatValue = ((RtFieldInfo)fields[i]).InternalGetValue(obj, false, false);
                if (!AreFieldValuesEqual(thisValue, thatValue))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 5
0
        public override bool Equals(Object obj)
        {
            BCLDebug.Perf(false, "ValueType::Equals is not fast.  " + this.GetType().FullName + " should override Equals(Object)");
            if (null == obj)
            {
                return(false);
            }
            RuntimeType thisType = (RuntimeType)this.GetType();
            RuntimeType thatType = (RuntimeType)obj.GetType();

            if (thatType != thisType)
            {
                return(false);
            }

            Object thisObj = (Object)this;
            Object thisResult, thatResult;

            // if there are no GC references in this object we can avoid reflection
            // and do a fast memcmp
            if (CanCompareBits(this))
            {
                return(FastEqualsCheck(thisObj, obj));
            }

            FieldInfo[] thisFields = thisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            for (int i = 0; i < thisFields.Length; i++)
            {
                thisResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(thisObj);
                thatResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(obj);

                if (thisResult == null)
                {
                    if (thatResult != null)
                    {
                        return(false);
                    }
                }
                else
                if (!thisResult.Equals(thatResult))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 6
0
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            RuntimeType thisType = (RuntimeType)this.GetType();
            RuntimeType thatType = (RuntimeType)obj.GetType();

            if (thatType != thisType)
            {
                return(false);
            }

            Object thisObj = this;
            Object thisResult, thatResult;

            FieldInfo[] thisFields = thisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            for (int i = 0; i < thisFields.Length; i++)
            {
                thisResult = ((RuntimeFieldInfo)thisFields[i]).GetValue(thisObj);
                thatResult = ((RuntimeFieldInfo)thisFields[i]).GetValue(obj);

                if (thisResult == null)
                {
                    if (thatResult != null)
                    {
                        return(false);
                    }
                }
                else if (!thisResult.Equals(thatResult))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 7
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            RuntimeType type  = (RuntimeType)base.GetType();
            RuntimeType type2 = (RuntimeType)obj.GetType();

            if (type2 != type)
            {
                return(false);
            }
            object a = this;

            if (CanCompareBits(this))
            {
                return(FastEqualsCheck(a, obj));
            }
            FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < fields.Length; i++)
            {
                object obj3 = ((RtFieldInfo)fields[i]).InternalGetValue(a, false);
                object obj4 = ((RtFieldInfo)fields[i]).InternalGetValue(obj, false);
                if (obj3 == null)
                {
                    if (obj4 != null)
                    {
                        return(false);
                    }
                }
                else if (!obj3.Equals(obj4))
                {
                    return(false);
                }
            }
            return(true);
        }
 private static MemberInfo[] GetSerializableMembers(RuntimeType type) {
     // get the list of all fields 
     FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
     int countProper = 0; 
     for (int i = 0;  i < fields.Length; i++) { 
         if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized)
             continue; 
         countProper++;
     }
     if (countProper != fields.Length) {
         FieldInfo[] properFields = new FieldInfo[countProper]; 
         countProper = 0;
         for (int i = 0;  i < fields.Length; i++) { 
             if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized) 
                 continue;
             properFields[countProper] = fields[i]; 
             countProper++;
         }
         return properFields;
     } 
     else
         return fields; 
 } 
Esempio n. 9
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);
        }
Esempio n. 11
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 obj1 = (object)this;

            FieldInfo[] fields = runtimeType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            for (int index = 0; index < fields.Length; ++index)
            {
                if (!Attribute.AreFieldValuesEqual(((RtFieldInfo)fields[index]).InternalGetValue(obj1, false, false), ((RtFieldInfo)fields[index]).InternalGetValue(obj, false, false)))
                {
                    return(false);
                }
            }
            return(true);
        }
 private static MemberInfo[] GetSerializableMembers(RuntimeType type)
 {
     FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
     int index = 0;
     for (int i = 0; i < fields.Length; i++)
     {
         if ((fields[i].Attributes & FieldAttributes.NotSerialized) != FieldAttributes.NotSerialized)
         {
             index++;
         }
     }
     if (index == fields.Length)
     {
         return fields;
     }
     FieldInfo[] infoArray2 = new FieldInfo[index];
     index = 0;
     for (int j = 0; j < fields.Length; j++)
     {
         if ((fields[j].Attributes & FieldAttributes.NotSerialized) != FieldAttributes.NotSerialized)
         {
             infoArray2[index] = fields[j];
             index++;
         }
     }
     return infoArray2;
 }