Пример #1
0
        internal static bool InitializeRows(CremaDataTable diffTable1, CremaDataTable diffTable2, CremaDataTable dataTable1, CremaDataTable dataTable2)
        {
            var differ        = new Differ();
            var inlineBuilder = new SideBySideDiffBuilder(differ);

            var rowText1 = dataTable1 == null ? string.Empty : GetString(dataTable1.Rows);
            var rowText2 = dataTable2 == null ? string.Empty : GetString(dataTable2.Rows);

            var rowDiff = inlineBuilder.BuildDiffModel(rowText1, rowText2);
            var types1  = rowDiff.OldText.Lines.Select(item => item.Type).ToArray();
            var types2  = rowDiff.NewText.Lines.Select(item => item.Type).ToArray();

            foreach (var item in diffTable1.Childs)
            {
                item.Rows.Clear();
            }
            diffTable1.Rows.Clear();

            foreach (var item in diffTable2.Childs)
            {
                item.Rows.Clear();
            }
            diffTable2.Rows.Clear();

            diffTable1.BeginLoad();
            diffTable2.BeginLoad();
            FillRows(diffTable1, dataTable1, rowDiff.OldText.Lines);
            FillRows(diffTable2, dataTable2, rowDiff.NewText.Lines);
            diffTable1.EndLoad();
            diffTable2.EndLoad();
            return(true);
        }
Пример #2
0
 private static void ImportRow(CremaDataTable dataTable, SerializationTable serializedTable)
 {
     dataTable.BeginLoad();
     foreach (var item in serializedTable.Rows)
     {
         if (dataTable.Parent == null)
         {
             var dataRow = dataTable.NewRow();
             ImportRow(dataRow, item, serializedTable.Columns);
             dataTable.Rows.Add(dataRow);
         }
         else
         {
             var parentRow = dataTable.Parent.Rows.First(i => i.RelationID == item.ParentID);
             var dataRow   = dataTable.NewRow(parentRow);
             ImportRow(dataRow, item, serializedTable.Columns);
             dataTable.Rows.Add(dataRow);
         }
     }
     dataTable.EndLoad();
 }