public bool IsEqual(object first, object second)
        {
            Type type = first.GetType();

            foreach (System.Reflection.PropertyInfo property in type.GetProperties())
            {
                object Object1Value = null;
                object Object2Value = null;

                if (type.GetProperty(property.Name).GetValue(first, null) != null)
                {
                    Object1Value = type.GetProperty(property.Name).GetValue(first, null);
                }

                if (type.GetProperty(property.Name).GetValue(second, null) != null)
                {
                    Object2Value = type.GetProperty(property.Name).GetValue(second, null);
                }

                ICompare compare = FactoryResolver.ResolveComparer(Object1Value);

                if (!compare.IsEqual(Object1Value, Object2Value))
                {
                    return(false);
                }
            }
            return(true);
        }
        public bool IsEqual(object first, object second)
        {
            var lstFirst  = ((IEnumerable)first).Cast <object>().ToList();
            var lstSecond = ((IEnumerable)second).Cast <object>().ToList();

            if (lstFirst.Count != lstSecond.Count)
            {
                return(false);
            }

            for (int iter = 0; iter < lstFirst.Count; iter++)
            {
                ICompare compare = FactoryResolver.ResolveComparer(lstFirst[iter]);

                if (!compare.IsEqual(lstFirst[iter], lstSecond[iter]))
                {
                    return(false);
                }
            }

            //if(!lstFirst.OrderBy(x => x).SequenceEqual(lstSecond))
            //    return false;

            return(true);
        }
Exemplo n.º 3
0
        public static bool AreSimilar <T>(T first, T second)
        {
            if (first == null || second == null)
            {
                return(true);
            }

            ICompare compare = FactoryResolver.ResolveComparer(first);

            return(compare.IsEqual(first, second));
        }