/// <summary> /// Constructs a <see cref="StringDifferenceOptions"/> from a given <see cref="StringDifferenceOptions"/>. /// </summary> /// <param name="other">The <see cref="StringDifferenceOptions"/> to use in constructing a new <see cref="StringDifferenceOptions"/>.</param> public StringDifferenceOptions(StringDifferenceOptions other) : this() { this.differenceType = other.DifferenceType; this.locality = other.Locality; this.ignoreTrimWhiteSpace = other.IgnoreTrimWhiteSpace; this.WordSplitBehavior = other.WordSplitBehavior; this.DetermineLocalityCallback = other.DetermineLocalityCallback; this.ContinueProcessingPredicate = other.ContinueProcessingPredicate; }
internal static DifferenceCollection <T> DifferenceSequences <T>(IList <T> left, IList <T> right, IList <T> originalLeft, IList <T> originalRight, ContinueProcessingPredicate <T> continueProcessingPredicate) { if (left == null) { throw new ArgumentNullException(nameof(left)); } if (right == null) { throw new ArgumentNullException(nameof(right)); } Microsoft.TeamFoundation.Diff.Copy.IDiffChange[] changes; if ((left.Count == 0) || (right.Count == 0)) { if ((left.Count == 0) && (right.Count == 0)) { changes = MaximalSubsequenceAlgorithm.Empty; } else { changes = new Microsoft.TeamFoundation.Diff.Copy.IDiffChange[1]; changes[0] = new Microsoft.TeamFoundation.Diff.Copy.DiffChange(0, left.Count, 0, right.Count); } } else { changes = ComputeMaximalSubsequence <T>(left, right, continueProcessingPredicate); } return(DiffChangeCollectionHelper <T> .Create(changes, originalLeft, originalRight)); }
private static Microsoft.TeamFoundation.Diff.Copy.IDiffChange[] ComputeMaximalSubsequence <T>(IList <T> left, IList <T> right, ContinueProcessingPredicate <T> continueProcessingPredicate) { var lcs = new Microsoft.TeamFoundation.Diff.Copy.LcsDiff <T>(); var diffs = lcs.Diff(left, right, EqualityComparer <T> .Default, (continueProcessingPredicate == null) ? (Microsoft.TeamFoundation.Diff.Copy.ContinueDifferencePredicate <T>)null : (int originalIndex, IList <T> originalSequence, int longestMatchSoFar) => { return(continueProcessingPredicate(originalIndex, originalSequence, longestMatchSoFar)); }); return(diffs); }
public IDifferenceCollection <T> DifferenceSequences <T>(IList <T> left, IList <T> right, ContinueProcessingPredicate <T> continueProcessingPredicate) { return(DifferenceSequences <T>(left, right, left, right, continueProcessingPredicate)); }