public ArrayList DiffReport() { ArrayList report = new ArrayList(); int num1 = this._dest.Count(); int num2 = this._source.Count(); if (num1 == 0) { if (num2 > 0) { report.Add((object)DiffResultSpan.CreateDeleteSource(0, num2)); } return(report); } if (num2 == 0) { report.Add((object)DiffResultSpan.CreateAddDestination(0, num1)); return(report); } this._matchList.Sort(); int curDest = 0; int curSource = 0; DiffResultSpan diffResultSpan = (DiffResultSpan)null; foreach (DiffResultSpan match in this._matchList) { if (!this.AddChanges(report, curDest, match.DestIndex, curSource, match.SourceIndex) && diffResultSpan != null) { diffResultSpan.AddLength(match.Length); } else { report.Add((object)match); } curDest = match.DestIndex + match.Length; curSource = match.SourceIndex + match.Length; diffResultSpan = match; } this.AddChanges(report, curDest, num1, curSource, num2); return(report); }
private bool AddChanges(ArrayList report, int curDest, int nextDest, int curSource, int nextSource) { bool flag = false; int num1 = nextDest - curDest; int num2 = nextSource - curSource; if (num1 > 0) { if (num2 > 0) { int length = Math.Min(num1, num2); report.Add((object)DiffResultSpan.CreateReplace(curDest, curSource, length)); if (num1 > num2) { curDest += length; report.Add((object)DiffResultSpan.CreateAddDestination(curDest, num1 - num2)); } else if (num2 > num1) { curSource += length; report.Add((object)DiffResultSpan.CreateDeleteSource(curSource, num2 - num1)); } } else { report.Add((object)DiffResultSpan.CreateAddDestination(curDest, num1)); } flag = true; } else if (num2 > 0) { report.Add((object)DiffResultSpan.CreateDeleteSource(curSource, num2)); flag = true; } return(flag); }