internal static DiffResult GetDiff(Mathertel.Diff.Item[] Results, string Source, string Destination, char Splitter) { DiffResult DResult = new DiffResult(); int n = 0; string[] aLines = Source.Split(Splitter); string[] bLines = Destination.Split(Splitter); foreach (Diff.Item Result in Results) { Diff.Item aItem = Result; // write unchanged lines while ((n < aItem.StartB) && (n < bLines.Length)) { DResult.UnChanged.Add(n + 1); DResult.UnChangedSections.Add(bLines[n]); n++; } // while // write deleted lines for (int m = 0; m < aItem.deletedA; m++) { DResult.Deleted.Add(aItem.StartA + m + 1); DResult.MissingAt.Add(n + 1); DResult.DeletedSections.Add(aLines[aItem.StartA + m]); } // for // write inserted lines while (n < aItem.StartB + aItem.insertedB) { DResult.Inserted.Add(n + 1); DResult.InsertedSections.Add(bLines[n]); n++; } // while } // while // write rest of unchanged lines while (n < bLines.Length) { DResult.UnChanged.Add(n + 1); DResult.UnChangedSections.Add(bLines[n]); n++; } // while return DResult; }
internal static DiffResult GetLineDiff(Mathertel.Diff.Item[] Results, string Source, string Destination) { return GetDiff(Results, Source, Destination, ' '); }