private void CompareEachRow(CompareParms parms)
        {
            DataTable dataTable1 = parms.Object1 as DataTable;
            DataTable dataTable2 = parms.Object2 as DataTable;

            for (int i = 0; i < Math.Min(dataTable1.Rows.Count, dataTable2.Rows.Count); i++)
            {
                string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "Rows", string.Empty, i);

                CompareParms childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = dataTable1.Rows[i],
                    Object2       = dataTable2.Rows[i],
                    BreadCrumb    = currentBreadCrumb
                };

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return;
                }
            }
        }
        public override void CompareType(CompareParms parms)
        {
            parms.Object1Type = parms.Object1?.GetType();
            parms.Object2Type = parms.Object2?.GetType();

            IDictionary <string, object> object1Properties = (IDictionary <string, object>)parms.Object1;
            IDictionary <string, object> object2Properties = (IDictionary <string, object>)parms.Object2;

            object object1 = null;
            object object2 = null;

            foreach (var propertyName in GetComparableProperties(object1Properties.Keys, object2Properties.Keys))
            {
                if (parms.Result.ExceededDifferences)
                {
                    return;
                }

                CompareParms childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = object1Properties.TryGetValue(propertyName, out object1) ? object1 : null,
                    Object2       = object2Properties.TryGetValue(propertyName, out object2) ? object2 : null,
                    BreadCrumb    = AddBreadCrumb(parms.Config, parms.BreadCrumb, propertyName)
                };

                RootComparer.Compare(childParms);
            }
        }
        private void CompareItems(CompareParms parms)
        {
            int         count       = 0;
            IEnumerator enumerator1 = ((IList)parms.Object1).GetEnumerator();
            IEnumerator enumerator2 = ((IList)parms.Object2).GetEnumerator();

            while (enumerator1.MoveNext() && enumerator2.MoveNext())
            {
                string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, string.Empty, string.Empty, count);

                CompareParms childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = enumerator1.Current,
                    Object2       = enumerator2.Current,
                    BreadCrumb    = currentBreadCrumb
                };

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return;
                }

                count++;
            }
        }
Beispiel #4
0
        private void CompareRowCollections(CompareParms parms)
        {
            DataTable dataTable1 = parms.Object1 as DataTable;
            DataTable dataTable2 = parms.Object2 as DataTable;

            if (null == dataTable1 || null == dataTable2)
            {
                return;
            }

            string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "Rows");

            CompareParms childParms = new CompareParms
            {
                Result        = parms.Result,
                Config        = parms.Config,
                ParentObject1 = parms.Object1,
                ParentObject2 = parms.Object2,
                Object1       = dataTable1.Rows,
                Object2       = dataTable2.Rows,
                BreadCrumb    = currentBreadCrumb,
            };


            RootComparer.Compare(childParms);

            if (parms.Result.ExceededDifferences)
            {
                return;
            }
        }
Beispiel #5
0
        private void CompareItems(CompareParms parms)
        {
            int count = 0;

            //Get enumerators by reflection
            MethodInfo  methodInfo  = Cache.GetMethod(parms.Object1Type, "GetEnumerator");
            IEnumerator enumerator1 = (IEnumerator)methodInfo.Invoke(parms.Object1, null);
            IEnumerator enumerator2 = (IEnumerator)methodInfo.Invoke(parms.Object2, null);

            while (enumerator1.MoveNext() && enumerator2.MoveNext())
            {
                string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, string.Empty, string.Empty, count);

                CompareParms childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = enumerator1.Current,
                    Object2       = enumerator2.Current,
                    BreadCrumb    = currentBreadCrumb
                };

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return;
                }

                count++;
            }
        }
        private void CompareEachItem(CompareParms parms)
        {
            var enumerator1 = ((IDictionary)parms.Object1).GetEnumerator();
            var enumerator2 = ((IDictionary)parms.Object2).GetEnumerator();

            while (enumerator1.MoveNext() && enumerator2.MoveNext())
            {
                string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "Key");

                CompareParms childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = enumerator1.Key,
                    Object2       = enumerator2.Key,
                    BreadCrumb    = currentBreadCrumb
                };

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return;
                }

                currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "Value");

                childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = enumerator1.Value,
                    Object2       = enumerator2.Value,
                    BreadCrumb    = currentBreadCrumb
                };

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return;
                }
            }
        }
        private void CompareProp(CompareParms parms, object prop1, object prop2, string propName)
        {
            string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, propName);

            CompareParms childParms = new CompareParms
            {
                Result        = parms.Result,
                Config        = parms.Config,
                ParentObject1 = parms.Object1,
                ParentObject2 = parms.Object2,
                Object1       = prop1,
                Object2       = prop2,
                BreadCrumb    = currentBreadCrumb
            };

            RootComparer.Compare(childParms);
        }
Beispiel #8
0
        private void CompareProp <T>(CompareParms parms, DataColumn col1, DataColumn col2, T prop1, T prop2, string propName)
        {
            if (parms.Result.ExceededDifferences)
            {
                return;
            }

            string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, propName);

            CompareParms childParms = new CompareParms();

            childParms.Result        = parms.Result;
            childParms.Config        = parms.Config;
            childParms.BreadCrumb    = currentBreadCrumb;
            childParms.ParentObject1 = col1;
            childParms.ParentObject2 = col2;
            childParms.Object1       = prop1;
            childParms.Object2       = prop2;

            RootComparer.Compare(childParms);
        }
Beispiel #9
0
        private void ModifyDefference(object original, object newest, object id, CompareParms parms)
        {
            //差异对比
            string       currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, string.Empty, string.Empty, id.ToString());
            CompareParms childParms        = new CompareParms
            {
                Result = parms.Result,
                Config = parms.Config,

                ParentObject1 = parms.Object1,
                ParentObject2 = parms.Object2,
                Object1       = original,
                Object2       = newest,
                BreadCrumb    = currentBreadCrumb
            };

            RootComparer.Compare(childParms);
            if (parms.Result.ExceededDifferences)
            {
                return;
            }
        }
        private void CompareItems(CompareParms parms)
        {
            int         count       = 0;
            IEnumerator enumerator1 = ((IList)parms.Object1)?.GetEnumerator();
            IEnumerator enumerator2 = ((IList)parms.Object2)?.GetEnumerator();

            var isNextObj1Exists = enumerator1 != null?enumerator1.MoveNext() : false;

            var isNextObj2Exists = enumerator2 != null?enumerator2.MoveNext() : false;

            while (isNextObj1Exists || isNextObj2Exists)
            {
                string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, string.Empty, string.Empty, count);

                CompareParms childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = isNextObj1Exists ? enumerator1.Current : null,
                    Object2       = isNextObj2Exists ? enumerator2.Current : null,
                    BreadCrumb    = currentBreadCrumb
                };

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return;
                }

                count++;
                isNextObj1Exists = enumerator1 != null?enumerator1.MoveNext() : false;

                isNextObj2Exists = enumerator2 != null?enumerator2.MoveNext() : false;
            }
        }
Beispiel #11
0
        private void CompareEachTable(CompareParms parms, DataSet dataSet1, DataSet dataSet2)
        {
            for (int i = 0; i < Math.Min(dataSet1.Tables.Count, dataSet2.Tables.Count); i++)
            {
                string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "Tables", string.Empty,
                                                         dataSet1.Tables[i].TableName);

                CompareParms childParms = new CompareParms();
                childParms.Result        = parms.Result;
                childParms.Config        = parms.Config;
                childParms.BreadCrumb    = currentBreadCrumb;
                childParms.ParentObject1 = dataSet1;
                childParms.ParentObject2 = dataSet2;
                childParms.Object1       = dataSet1.Tables[i];
                childParms.Object2       = dataSet2.Tables[i];

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return;
                }
            }
        }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DatasetComparer(RootComparer rootComparer)
     : base(rootComparer)
 {
 }
Beispiel #13
0
 public DateTimeDeltaComparer(RootComparer rootComparer, TimeSpan?delta = null) : base(rootComparer)
 {
     _delta = delta ?? TimeSpan.FromSeconds(1);
 }
 /// <summary>
 /// Protected constructor that references the root comparer
 /// </summary>
 /// <param name="rootComparer">The root comparer.</param>
 public ByteArrayComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DictionaryComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #16
0
        private bool ColumnsDifferent(CompareParms parms)
        {
            DataTable dataTable1 = parms.Object1 as DataTable;
            DataTable dataTable2 = parms.Object2 as DataTable;

            if (dataTable1 == null)
            {
                throw new ArgumentException("parms.Object1");
            }

            if (dataTable2 == null)
            {
                throw new ArgumentException("parms.Object2");
            }

            if (dataTable1.Columns.Count != dataTable2.Columns.Count)
            {
                Difference difference = new Difference
                {
                    ParentObject1     = new WeakReference(parms.ParentObject1),
                    ParentObject2     = new WeakReference(parms.ParentObject2),
                    PropertyName      = parms.BreadCrumb,
                    Object1Value      = dataTable1.Columns.Count.ToString(CultureInfo.InvariantCulture),
                    Object2Value      = dataTable2.Columns.Count.ToString(CultureInfo.InvariantCulture),
                    ChildPropertyName = "Columns.Count",
                    Object1           = new WeakReference(parms.Object1),
                    Object2           = new WeakReference(parms.Object2)
                };

                AddDifference(parms.Result, difference);

                if (parms.Result.ExceededDifferences)
                {
                    return(true);
                }
            }

            foreach (var i in Enumerable.Range(0, dataTable1.Columns.Count))
            {
                string currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "Columns", string.Empty, i);

                CompareParms childParms = new CompareParms
                {
                    Result        = parms.Result,
                    Config        = parms.Config,
                    ParentObject1 = parms.Object1,
                    ParentObject2 = parms.Object2,
                    Object1       = dataTable1.Columns[i],
                    Object2       = dataTable2.Columns[i],
                    BreadCrumb    = currentBreadCrumb
                };

                RootComparer.Compare(childParms);

                if (parms.Result.ExceededDifferences)
                {
                    return(true);
                }
            }

            return(false);
        }
 /// <summary>
 /// Protected constructor that references the root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 protected BaseTypeComparer(RootComparer rootComparer)
 {
     RootComparer = rootComparer;
 }
 /// <summary>
 /// Constructor for the class comparer
 /// </summary>
 /// <param name="rootComparer">The root comparer instantiated by the RootComparerFactory</param>
 public ClassComparer(RootComparer rootComparer) : base(rootComparer)
 {
     _propertyComparer = new PropertyComparer(rootComparer);
     _fieldComparer = new FieldComparer(rootComparer);
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DateTimeOffSetComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public RuntimeTypeComparer(RootComparer rootComparer)
     : base(rootComparer)
 {}
Beispiel #21
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public StringComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor with a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public FieldComparer(RootComparer rootComparer)
 {
     _rootComparer = rootComparer;
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public PointerComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #24
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public ListComparer(RootComparer rootComparer) : base(rootComparer)
 {
     
 }
 /// <summary>
 /// Protected constructor that references the root comparer
 /// </summary>
 /// <param name="rootComparer">The root comparer.</param>
 public ByteArrayComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DictionaryComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 public DomainObjectComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public EnumerableComparer(RootComparer rootComparer) : base(rootComparer)
 {
     _compareIList = new ListComparer(rootComparer);
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DataTableComparer(RootComparer rootComparer)
     : base(rootComparer)
 {
 }
Beispiel #30
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DoubleComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #31
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DataTableComparer(RootComparer rootComparer)
     : base(rootComparer)
 {
 }
Beispiel #32
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public IndexerComparer(RootComparer rootComparer)
 {
     _rootComparer = rootComparer;
 }
Beispiel #33
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DateComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public SimpleTypeComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
        private void CompareEachItem(CompareParms parms)
        {
            var dict1 = ((IDictionary)parms.Object1);
            var dict2 = ((IDictionary)parms.Object2);

            if (dict1 != null)
            {
                string       currentBreadCrumb = "";
                CompareParms childParms        = null;

                foreach (var key in dict1.Keys)
                {
                    currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "[" + key.ToString() + "].Value");

                    childParms = new CompareParms
                    {
                        Result        = parms.Result,
                        Config        = parms.Config,
                        ParentObject1 = parms.Object1,
                        ParentObject2 = parms.Object2,
                        Object1       = dict1[key],
                        Object2       = (dict2 != null) ? dict2[key] : null,
                        BreadCrumb    = currentBreadCrumb
                    };

                    RootComparer.Compare(childParms);

                    if (parms.Result.ExceededDifferences)
                    {
                        return;
                    }
                }
            }

            if (dict2 != null)
            {
                string       currentBreadCrumb = "";
                CompareParms childParms        = null;

                foreach (var key in dict2.Keys)
                {
                    currentBreadCrumb = AddBreadCrumb(parms.Config, parms.BreadCrumb, "[" + key.ToString() + "].Value");

                    childParms = new CompareParms
                    {
                        Result        = parms.Result,
                        Config        = parms.Config,
                        ParentObject1 = parms.Object1,
                        ParentObject2 = parms.Object2,
                        Object1       = (dict1 != null && dict1.Contains(key)) ? dict1[key] : null,
                        Object2       = dict2[key],
                        BreadCrumb    = currentBreadCrumb
                    };

                    RootComparer.Compare(childParms);

                    if (parms.Result.ExceededDifferences)
                    {
                        return;
                    }
                }
            }
        }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public PropertyComparer(RootComparer rootComparer)
 {
     _rootComparer    = rootComparer;
     _indexerComparer = new IndexerComparer(rootComparer);
 }
Beispiel #37
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DateTimeOffSetComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Protected constructor that references the root comparer
 /// </summary>
 /// <param name="rootComparer">The root comparer.</param>
 public FontComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 public FirstNullClassComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #40
0
 public ValueObjectComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #41
0
 /// <summary>
 /// Constructor with a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public FieldComparer(RootComparer rootComparer)
 {
     _rootComparer = rootComparer;
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public IpEndPointComparer(RootComparer rootComparer)
     : base(rootComparer)
 {}
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public SimpleTypeComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public TimespanComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #45
0
 public EmployeeComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #46
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public HashSetComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public DoubleComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IgnoreOrderLogic"/> class.
 /// </summary>
 /// <param name="rootComparer">The root comparer.</param>
 public IgnoreOrderLogic(RootComparer rootComparer)
 {
     _rootComparer = rootComparer;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IgnoreOrderLogic"/> class.
 /// </summary>
 /// <param name="rootComparer">The root comparer.</param>
 public IgnoreOrderLogic(RootComparer rootComparer)
 {
     _rootComparer = rootComparer;
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public PropertyComparer(RootComparer rootComparer)
 {
     _rootComparer = rootComparer;
     _indexerComparer = new IndexerComparer(rootComparer);
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public ListComparer(RootComparer rootComparer) : base(rootComparer)
 {
     _propertyComparer = new PropertyComparer(rootComparer);
     _fieldComparer    = new FieldComparer(rootComparer);
 }
 /// <summary>
 /// Constructor with a default root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public EnumComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
Beispiel #53
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public HashSetComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public UriComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }