private void PerformOperation(DiffOperation operation) { switch (operation.Action) { case DiffAction.equal: this.ProcessEqualOperation(operation); break; case DiffAction.delete: this.ProcessDeleteOperation(operation, "diffdel"); break; case DiffAction.insert: this.ProcessInsertOperation(operation, "diffins"); break; case DiffAction.none: break; case DiffAction.replace: this.ProcessReplaceOperation(operation); break; default: break; } }
private void ProcessEqualOperation(DiffOperation operation) { var result = this.newWords.Where((s, pos) => pos >= operation.StartInNew && pos < operation.EndInNew).ToArray(); this.content.Append(String.Join("", result)); }
private void ProcessDeleteOperation(DiffOperation operation, string cssClass) { var text = this.oldWords.Where((s, pos) => pos >= operation.StartInOld && pos < operation.EndInOld).ToList(); this.InsertTag("del", cssClass, text); }
private void ProcessInsertOperation(DiffOperation operation, string cssClass) { this.InsertTag("ins", cssClass, this.newWords.Where((s, pos) => pos >= operation.StartInNew && pos < operation.EndInNew).ToList()); }
private void ProcessReplaceOperation(DiffOperation operation) { this.ProcessDeleteOperation(operation, "diffmod"); this.ProcessInsertOperation(operation, "diffmod"); }