public IHierarchicalDifferenceCollection DiffSnapshotSpans(SnapshotSpan leftSpan, SnapshotSpan rightSpan, StringDifferenceOptions differenceOptions, Func <ITextSnapshotLine, string> getLineTextCallback) { StringDifferenceTypes type; ITokenizedStringListInternal left; ITokenizedStringListInternal right; if (differenceOptions.DifferenceType.HasFlag(StringDifferenceTypes.Line)) { type = StringDifferenceTypes.Line; left = new SnapshotLineList(leftSpan, getLineTextCallback, differenceOptions); right = new SnapshotLineList(rightSpan, getLineTextCallback, differenceOptions); } else if (differenceOptions.DifferenceType.HasFlag(StringDifferenceTypes.Word)) { type = StringDifferenceTypes.Word; left = new WordDecompositionList(leftSpan, differenceOptions); right = new WordDecompositionList(rightSpan, differenceOptions); } else if (differenceOptions.DifferenceType.HasFlag(StringDifferenceTypes.Character)) { type = StringDifferenceTypes.Character; left = new CharacterDecompositionList(leftSpan); right = new CharacterDecompositionList(rightSpan); } else { throw new ArgumentOutOfRangeException("differenceOptions"); } return(DiffText(left, right, type, differenceOptions)); }
public IHierarchicalDifferenceCollection DiffStrings(string leftString, string rightString, StringDifferenceOptions differenceOptions) { if (leftString == null) { throw new ArgumentNullException(nameof(leftString)); } if (rightString == null) { throw new ArgumentNullException(nameof(rightString)); } StringDifferenceTypes type; ITokenizedStringListInternal left; ITokenizedStringListInternal right; if (differenceOptions.DifferenceType.HasFlag(StringDifferenceTypes.Line)) { type = StringDifferenceTypes.Line; left = new LineDecompositionList(leftString, differenceOptions.IgnoreTrimWhiteSpace); right = new LineDecompositionList(rightString, differenceOptions.IgnoreTrimWhiteSpace); } else if (differenceOptions.DifferenceType.HasFlag(StringDifferenceTypes.Word)) { type = StringDifferenceTypes.Word; left = new WordDecompositionList(leftString, differenceOptions); right = new WordDecompositionList(rightString, differenceOptions); } else if (differenceOptions.DifferenceType.HasFlag(StringDifferenceTypes.Character)) { type = StringDifferenceTypes.Character; left = new CharacterDecompositionList(leftString); right = new CharacterDecompositionList(rightString); } else { throw new ArgumentOutOfRangeException("differenceOptions"); } return(DiffText(left, right, type, differenceOptions)); }