Beispiel #1
0
        public virtual bool Equals(T other)
        {
            if ((object)other == null)
            {
                return(false);
            }

            Type t         = GetType();
            Type otherType = other.GetType();

            if (t != otherType)
            {
                return(false);
            }

            FieldInfo[] fields = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            foreach (FieldInfo field in fields)
            {
                object value1 = field.GetValue(other);
                object value2 = field.GetValue(this);

                if (value1 == null)
                {
                    if (value2 != null)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (t.IsArray)
                    {
                        if (!Equatable.ArraysAreEqual(value1 as IList, value2 as IList))
                        {
                            return(false);
                        }
                    }

                    if (!value1.Equals(value2))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }