Beispiel #1
0
        public override bool Push(char c)
        {
            if (this.isFirstChar && DelimitedParserStateQuote.IsQuote(c))
            {
                this.ChangeState(new DelimitedParserStateQuote(this.Parser));
            }
            else if (c == this.Delimiter)
            {
                this.Append();
                this.ChangeState(new DelimitedParserStateCapture(this.Parser));
            }
            else if (c == '\r')
            {
                this.Append();
                this.ChangeState(new DelimitedParserStateNewLine(this.Parser));
            }
            else if (c == '\n')
            {
                this.Append();
                this.ChangeState(new DelimitedParserStateCapture(this.Parser));
            }
            else
            {
                this.Accumulate(c);
            }

            this.isFirstChar = false;
            return(true);
        }
        public override bool Push(char c)
        {
            if (this.Delimiter == c && this.isPrevCharQuote)
            {
                this.Append();
                this.ChangeState(new DelimitedParserStateCapture(this.Parser));
            }
            else if (DelimitedParserStateQuote.IsQuote(c) && !this.isPrevCharQuote)
            {
                this.isPrevCharQuote = true;
            }
            else if (DelimitedParserStateQuote.IsQuote(c) && this.isPrevCharQuote)
            {
                this.Accumulate(c);
                this.isPrevCharQuote = false;
            }
            else
            {
                this.Accumulate(c);
            }

            return(true);
        }
        public void DelimitedParseStateQuote_IsQuoteChar()
        {
            Assert.True(DelimitedParserStateQuote.IsQuote('"'));

            Assert.False(DelimitedParserStateQuote.IsQuote('a'));
        }