private static CharacterCountingIterator GetCharacterCountingIterator(this ISegment segment, int startIndex) { Location startLocation = new Location(segment, true); CharacterCountingIterator counter = new CharacterCountingIterator(startLocation, GetStartCountingVisitor, GetEndCountingVisitor); while (counter.CharacterCount <= startIndex) { if (!counter.MoveNext()) { break; } } counter.MovePrevious(); return(counter); }
private static CharacterCountingIterator GetCharacterCountingIterator(this ISegment segment, int startIndex) { Location startLocation = new Location(segment, true); CharacterCountingIterator counter = new CharacterCountingIterator(startLocation, () => new StartOfItemCharacterCounterNoTagsVisitor(), () => new EndOfItemCharacterCounterNoTagsVisitor()); while (counter.CharacterCount <= startIndex) { if (!counter.MoveNext()) { break; } } counter.MovePrevious(); return(counter); }