Esempio n. 1
0
        public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken)
        {
            var peek = input.PeekUntil(x => x.Last() == ':');

            Name = new string(peek.Take(peek.Count - 1).ToArray());
            input.BacktrackPeek(1);
            return(Parent);
        }
Esempio n. 2
0
        public void Backtrack_peek_should_move_peek_index_backwards()
        {
            var chars      = Autofixture.CreateMany <char>(10).ToList();
            var enumerator = chars.GetEnumerator();
            var seeker     = new BufferedSeeker(enumerator);

            // Act
            seeker.Peek();
            seeker.Peek();
            seeker.BacktrackPeek(2);
            var result = seeker.Peek();

            // Assert
            result.Should().Be(chars.First());
            seeker.PeakIndex.Should().Be(1);
        }
Esempio n. 3
0
        public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken)
        {
            switch (lastToken)
            {
            case HeaderField token:
                Headers.Add(token.Name, token.Value);
                ProcessHeaders(token.Name, token.Value);
                break;
            }

            var peek = input.PeekUntil(x => x.Count == 2);

            input.BacktrackPeek(2);
            if (peek.First() == '\r' && peek.Last() == '\n')
            {
                return(Parent);
            }
            return(new HeaderField(this));
        }