internal static string[] DoSideBySideDiff(string SourceText, string DestinationText) { string[] Result = new string[3]; Differ DiffMaker = new Differ(); SideBySideDiffBuilder SideBySideDiffer = new SideBySideDiffBuilder(DiffMaker); SideBySideDiffModel SideBySideDiffResult = SideBySideDiffer.BuildDiffModel(SourceText, DestinationText); int DiffLevel = IronDiffer.GetLevel(SideBySideDiffResult, SourceText, DestinationText); Result[0] = FullDiff(SideBySideDiffResult.OldText.Lines); Result[1] = FullDiff(SideBySideDiffResult.NewText.Lines); Result[2] = DiffLevel.ToString(); return(Result); }
void AnalyzeResponseContent(int Index, BehaviourAnalysisResult Result) { DiffPlex.DiffBuilder.Model.SideBySideDiffModel DiffResult = IronDiffer.GetDiff(this.BaseLineSession.Response.BodyString, this.Logs[Index].Response.BodyString); int DiffLevel = IronDiffer.GetLevel(DiffResult, this.BaseLineSession.Response.BodyString, this.Logs[Index].Response.BodyString); List <string> InsertedStrings = IronDiffer.GetInsertedStrings(DiffResult); List <string> DeletedStrings = IronDiffer.GetDeletedStrings(DiffResult); List <string> KeywordsFound = new List <string>(); foreach (string Keyword in this.Keywords.Keys) { if (this.Logs[Index].Response.BodyString.IndexOf(Keyword, 0, StringComparison.OrdinalIgnoreCase) > -1) { KeywordsFound.Add(Keyword); } } int NoOfInsertedChars = 0; foreach (string InsertedString in InsertedStrings) { NoOfInsertedChars += InsertedString.Length; if (KeywordsFound.Count > 0) { foreach (string Keyword in KeywordsFound) { if (this.Keywords[Keyword].IsMatch(InsertedString)) { if (!Result.ResponseKeywordsResult.Contains(Keyword)) { Result.ResponseKeywordsResult.Add(Keyword); } } } } } if (NoOfInsertedChars > BodyDiffMinInterestingInsertedChars) { Result.ResponseContentResult = NoOfInsertedChars; } }
public static int DiffLevel(string Source, string Destination) { return(IronDiffer.GetLevel(Source, Destination)); }