Exemplo n.º 1
0
        public void RestoreToMark(MarkedPosition position)
        {
            long delta = this.Position - position.streamPos;

            if (delta > MaxRestoreLength)
            {
                this.stream.Position = this.streamPosition = position.streamPos;
                this.FillBufferFromStreamPosition();
            }
            else
            {
                this.bufferIndex -= (uint)delta;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads the stream into the string builder until the last end marker on the line is hit.
        /// </summary>
        public void ReadAsciiStringUpToLastBeforeTrue(char endMarker, StringBuilder sb, Func <byte, bool> predicate)
        {
            StringBuilder  buffer = new StringBuilder();
            MarkedPosition mp     = this.MarkPosition();

            while (predicate(this.Current) && !this.EndOfStream)
            {
                if (this.Current == endMarker)
                {
                    sb.Append(buffer);
                    buffer.Clear();
                    mp = this.MarkPosition();
                }

                buffer.Append((char)this.Current);
                this.MoveNext();
            }

            this.RestoreToMark(mp);
        }