public static bool EnumerableCompare <T>(IEnumerable <T> a, IEnumerable <T> b) where T : class
        {
            bool equals;
            var  x = 0;

            if (CompareExtensions.CheckNullEquality(a, b, out equals))
            {
                return(equals);
            }

            if (a.Count() != b.Count())
            {
                return(false);
            }

            foreach (var itemA in a)
            {
                var itemB = b.ElementAt(x);

                if (!itemA.Equals(itemB))
                {
                    return(false);
                }

                x++;
            }

            return(true);
        }
Exemple #2
0
        public int CompareTo(HSLColor other)
        {
            bool equals;

            if (CompareExtensions.CheckNullEquality(this, other, out equals))
            {
                return(equals ? 0 : 1);
            }
            else
            {
                var compare = CompareExtensions.AllAreTrue(
                    this.Hue == other.Hue,
                    this.Saturation == other.Saturation,
                    this.Luminosity == other.Luminosity);

                return(compare ? 0 : 1);
            }
        }
        public static bool ReflectCompare <T>(T a, T b, Func <string, T, T, bool> propertyCompare)
        {
            bool equals;

            if (CompareExtensions.CheckNullEquality(a, b, out equals))
            {
                return(equals);
            }

            foreach (var property in typeof(T).GetProperties(System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public))
            {
                if (!propertyCompare(property.Name, a, b))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #4
0
        // kn - best approach to equality comparisons

        private static bool Equals(StatusEntry a, StatusEntry b)
        {
            bool equals;

            if (CompareExtensions.CheckNullEquality(a, b, out equals))
            {
                return(equals);
            }
            else
            {
                if (a.StatusText != b.StatusText || a.ForeColor != b.ForeColor || a.BackColor != b.BackColor)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }