Пример #1
0
 internal Enumerator(CharacterStream target)
 {
     Monitor.Enter(_target._syncRoot);
     try
     {
     }
     finally { Monitor.Exit(_target._syncRoot); }
     _position = (_startIndex = (_target = target)._startIndex) - 1;
     _endIndex = target._endIndex;
 }
Пример #2
0
 /// <summary>
 /// Splits the current <see cref="CharacterStream"/> into a new <see cref="CharacterStream"/> after the specified length.
 /// </summary>
 /// <param name="length">The number of characters to retain in the current <see cref="CharacterStream"/>.</param>
 /// <returns>A <see cref="CharacterStream"/> containing the characters that were in the current <see cref="CharacterStream"/> beyond the specified <paramref name="length"/>.</returns>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="length"/> is less than zero or greater than <see cref="Count"/>.</exception>
 public CharacterStream Split(int length)
 {
     Monitor.Enter(_syncRoot);
     try
     {
         if (length < 0 || length > Count)
         {
             throw new ArgumentOutOfRangeException("length");
         }
         CharacterStream result = new CharacterStream((length < Count) ? _value.Substring(_startIndex + length, Count - length) : string.Empty);
         _startIndex += length;
         Count       -= length;
         return(result);
     }
     finally { Monitor.Exit(_syncRoot); }
 }