/// <summary> /// Instantiates a new <see cref="Enumerator"/> instance for <paramref name="tokenizer"/>. /// </summary> /// <param name="tokenizer">The containing <see cref="TrimmingTokenizer"/>.</param> public Enumerator(TrimmingTokenizer tokenizer) { _tokenizer = tokenizer; _count = 0; _enumerator = tokenizer._tokenizer.GetEnumerator(); _remainder = StringSegment.Empty; }
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); }