Esempio n. 1
0
 private static bool AreFieldValuesEqual(object thisValue, object thatValue)
 {
     if (thisValue == null && thatValue == null)
     {
         return(true);
     }
     if (thisValue == null || thatValue == null)
     {
         return(false);
     }
     if (thisValue.GetType().IsArray)
     {
         if (!thisValue.GetType().Equals(thatValue.GetType()))
         {
             return(false);
         }
         Array array1 = thisValue as Array;
         Array array2 = thatValue as Array;
         if (array1.Length != array2.Length)
         {
             return(false);
         }
         for (int index = 0; index < array1.Length; ++index)
         {
             if (!Attribute.AreFieldValuesEqual(array1.GetValue(index), array2.GetValue(index)))
             {
                 return(false);
             }
         }
     }
     else if (!thisValue.Equals(thatValue))
     {
         return(false);
     }
     return(true);
 }
Esempio n. 2
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);
        }