/// <inheritdoc /> public bool MoveNext() { // Do nothing except return false if _maxCount == 0. var result = false; if (_count < _tokenizer._maxCount) { // Keep moving until enumeration is done or we find a non-empty (and non-whitespace) segment. do { result = _enumerator.MoveNext(); }while (result && StringSegment.IsNullOrEmpty(Current)); if (result) { if (_count + 1 >= _tokenizer._maxCount) { _remainder = _tokenizer._originalString .Subsegment(Current.Offset - _tokenizer._originalString.Offset) .Trim(); } _count++; } } return(result); }
private static bool TryGetNextSegment(ref StringTokenizer.Enumerator enumerator, out StringSegment segment) { while (enumerator.MoveNext()) { if (enumerator.Current.HasValue && enumerator.Current.Length > 0) { segment = enumerator.Current; return(true); } } segment = default(StringSegment); return(false); }
public int UsingUnsafeStringTokenizer() { StringTokenizer tokenizer = new StringTokenizer(Text, _separators, Options); int count = 0; StringTokenizer.Enumerator e = tokenizer.GetEnumerator(); while (e.MoveNext()) { StringSegment segment = e.Current; StringSegment value = segment.UnsafeTrim(); count++; } return(count); }