Example #1
0
        public static void InitializeMembers(CremaDataType diffSource1, CremaDataType diffSource2, CremaDataType dataType1, CremaDataType dataType2)
        {
            //var hashValue1 = dataType1?.HashValue;
            //var hashValue2 = dataType2?.HashValue;

            diffSource1.BeginLoadData();
            diffSource2.BeginLoadData();
            //if (dataType1.HashValue != null && dataType1.HashValue == dataType2.HashValue)
            {
                var inlineBuilder = new SideBySideDiffBuilder(new Differ());
                var memberText1   = dataType1 == null?DiffInternalUtility.GetString(dataType2.Items) : DiffInternalUtility.GetString(dataType1.Items);

                var memberText2 = dataType2 == null?DiffInternalUtility.GetString(dataType1.Items) : DiffInternalUtility.GetString(dataType2.Items);

                var memberDiff = inlineBuilder.BuildDiffModel(memberText1, memberText2);
                DiffInternalUtility.FillMember(diffSource1, dataType1 ?? dataType2, memberDiff.OldText.Lines);
                DiffInternalUtility.FillMember(diffSource2, dataType2 ?? dataType1, memberDiff.NewText.Lines);
            }
            //else
            //{

            //}
            diffSource1.EndLoadData();
            diffSource2.EndLoadData();
        }
Example #2
0
        private void InitializeItems()
        {
            this.diffSource1.MemberChanged -= DiffSource1_MemberChanged;
            this.diffSource2.MemberChanged -= DiffSource2_MemberChanged;
            this.diffSource1.MemberDeleted -= DiffSource1_MemberDeleted;
            this.diffSource2.MemberDeleted -= DiffSource2_MemberDeleted;
            DiffInternalUtility.InitializeMembers(this.diffSource1, this.diffSource2, this.dataType1, this.dataType2);
            {
                this.itemList.Clear();
                this.itemList.Capacity = this.diffSource1.Items.Count;
                for (var i = 0; i < this.diffSource1.Items.Count; i++)
                {
                    var item = new DiffDataTypeMember(this, i);
                    this.itemList.Add(item);
                }

                for (var i = 0; i < this.itemList.Count; i++)
                {
                    var item = this.itemList[i];
                    item.Update();
                }

                this.diffSource1.AcceptChanges();
                this.diffSource2.AcceptChanges();
            }
            this.diffSource1.MemberChanged += DiffSource1_MemberChanged;
            this.diffSource2.MemberChanged += DiffSource2_MemberChanged;
            this.diffSource1.MemberDeleted += DiffSource1_MemberDeleted;
            this.diffSource2.MemberDeleted += DiffSource2_MemberDeleted;
        }
Example #3
0
        private void InitializeTables(IProgress progress)
        {
            var tables1 = this.dataSet1.Tables.Where(item => item.Parent == null && item.TemplatedParent == null)
                          .OrderBy(item => item.Name)
                          .ToList();
            var tables2 = this.dataSet2.Tables.Where(item => item.Parent == null && item.TemplatedParent == null)
                          .OrderBy(item => item.Name)
                          .ToList();
            var tableList = new List <DiffDataTable>();

            foreach (var item in tables1.ToArray())
            {
                var count = tables2.Count(i => i.TableID == item.TableID);
                if (count == 1)
                {
                    var dataTable1 = item;
                    var dataTable2 = tables2.Single(i => i.TableID == item.TableID);
                    var tableName1 = dataTable1.TableName != dataTable2.TableName ? DiffUtility.DiffDummyKey + dataTable1.TableName : dataTable2.TableName;
                    var tableName2 = dataTable2.TableName;
                    var diffTable1 = DiffDataTable.Create(this.diffSet1, tableName1);
                    var diffTable2 = DiffDataTable.Create(this.diffSet2, tableName2);
                    DiffInternalUtility.SyncColumns(diffTable1, diffTable2, dataTable1, dataTable2);
                    var diffTable    = new DiffDataTable(diffTable1, diffTable2, dataTable1, dataTable2, this);
                    var diffTemplate = new DiffTemplate(diffTable1, diffTable2, dataTable1, dataTable2)
                    {
                        DiffTable = diffTable
                    };
                    diffTable.Template = diffTemplate;
                    diffTable.InitializeChilds();
                    tableList.Add(diffTable);
                    tables1.Remove(dataTable1);
                    tables2.Remove(dataTable2);
                }
            }

            foreach (var item in tables1)
            {
                var dataTable1 = item;
                if (this.dataSet2.Tables.Contains(dataTable1.TableName) == true)
                {
                    var dataTable2 = this.dataSet2.Tables[dataTable1.TableName];
                    var diffTable1 = DiffDataTable.Create(this.diffSet1, dataTable1.TableName);
                    var diffTable2 = DiffDataTable.Create(this.diffSet2, dataTable2.TableName);
                    DiffInternalUtility.SyncColumns(diffTable1, diffTable2, dataTable1, dataTable2);
                    var diffTable    = new DiffDataTable(diffTable1, diffTable2, dataTable1, dataTable2, this);
                    var diffTemplate = new DiffTemplate(diffTable1, diffTable2, dataTable1, dataTable2)
                    {
                        DiffTable = diffTable
                    };
                    diffTable.Template = diffTemplate;
                    diffTable.InitializeChilds();
                    tableList.Add(diffTable);
                    tables2.Remove(dataTable2);
                }
                else
                {
                    var diffTable1 = DiffDataTable.Create(new CremaDataSet(), dataTable1.TableName);
                    var diffTable2 = DiffDataTable.Create(new CremaDataSet(), dataTable1.TableName);
                    DiffInternalUtility.SyncColumns(diffTable1, diffTable2, dataTable1, null);
                    var diffTable    = new DiffDataTable(diffTable1, diffTable2, dataTable1, null, this);
                    var diffTemplate = new DiffTemplate(diffTable1, diffTable2, dataTable1, null)
                    {
                        DiffTable = diffTable
                    };
                    diffTable.Template = diffTemplate;
                    diffTable.InitializeChilds();
                    tableList.Add(diffTable);
                }
            }

            foreach (var item in tables2)
            {
                var dataTable2 = item;
                var diffTable1 = DiffDataTable.Create(this.diffSet1, dataTable2.TableName);
                var diffTable2 = DiffDataTable.Create(this.diffSet2, dataTable2.TableName);
                DiffInternalUtility.SyncColumns(diffTable1, diffTable2, null, dataTable2);
                var diffTable    = new DiffDataTable(diffTable1, diffTable2, null, dataTable2, this);
                var diffTemplate = new DiffTemplate(diffTable1, diffTable2, null, dataTable2)
                {
                    DiffTable = diffTable
                };
                diffTable.Template = diffTemplate;
                diffTable.InitializeChilds();
                tableList.Add(diffTable);
            }

            foreach (var item in tableList.ToArray())
            {
                item.InitializeDerivedTables();
            }

            foreach (var item in tableList.ToArray())
            {
                tableList.AddRange(item.DerivedTables);
            }

            tableList.AsParallel().ForAll(item => item.DiffTemplate());
            tableList.AsParallel().ForAll(item => item.Diff());

            this.tables = tableList.OrderBy(item => item.SourceItem1.TableName).ToArray();
        }