private void ReadStringIntoBuffer(char quote)
        {
            char c;

            while (true)
            {
                c = this.MoveNext();
                char c2 = c;
                if (c2 != '\0')
                {
                    if (c2 != '"' && c2 != '\'')
                    {
                        if (c2 != '\\')
                        {
                            this._buffer.Append(c);
                        }
                        else
                        {
                            if ((c = this.MoveNext()) != '\0' || !this._end)
                            {
                                char c3 = c;
                                switch (c3)
                                {
                                case 'n':
                                    this._buffer.Append('\n');
                                    continue;

                                case 'o':
                                case 'p':
                                case 'q':
                                case 's':
IL_CA:
                                    if (c3 == '"' || c3 == '\'' || c3 == '/')
                                    {
                                        this._buffer.Append(c);
                                        continue;
                                    }
                                    if (c3 == '\\')
                                    {
                                        this._buffer.Append('\\');
                                        continue;
                                    }
                                    if (c3 == 'b')
                                    {
                                        this._buffer.Append('\b');
                                        continue;
                                    }
                                    if (c3 != 'f')
                                    {
                                        goto Block_11;
                                    }
                                    this._buffer.Append('\f');
                                    continue;

                                case 'r':
                                    this._buffer.Append('\r');
                                    continue;

                                case 't':
                                    this._buffer.Append('\t');
                                    continue;

                                case 'u':
                                {
                                    char[] array = new char[4];
                                    for (int i = 0; i < array.Length; i++)
                                    {
                                        if ((c = this.MoveNext()) == '\0' && this._end)
                                        {
                                            goto IL_1B0;
                                        }
                                        array[i] = c;
                                    }
                                    char value = Convert.ToChar(int.Parse(new string(array), 515, NumberFormatInfo.get_InvariantInfo()));
                                    this._buffer.Append(value);
                                    continue;
                                }
                                }
                                goto IL_CA;
                            }
                            goto IL_25D;
                        }
                    }
                    else
                    {
                        if (c == quote)
                        {
                            return;
                        }
                        this._buffer.Append(c);
                    }
                }
                else
                {
                    if (this._end)
                    {
                        break;
                    }
                    this._buffer.Append('\0');
                }
            }
            throw this.CreateJsonReaderException("Unterminated string. Expected delimiter: {0}. Line {1}, position {2}.", new object[]
            {
                quote,
                this._currentLineNumber,
                this._currentLinePosition
            });
Block_11:
            throw this.CreateJsonReaderException("Bad JSON escape sequence: {0}. Line {1}, position {2}.", new object[]
            {
                "\\" + c,
                this._currentLineNumber,
                this._currentLinePosition
            });
IL_1B0:
            throw this.CreateJsonReaderException("Unexpected end while parsing unicode character. Line {0}, position {1}.", new object[]
            {
                this._currentLineNumber,
                this._currentLinePosition
            });
IL_25D:
            throw this.CreateJsonReaderException("Unterminated string. Expected delimiter: {0}. Line {1}, position {2}.", new object[]
            {
                quote,
                this._currentLineNumber,
                this._currentLinePosition
            });
        }
Пример #2
0
 static JsonWriter()
 {
     JsonWriter.number_format = NumberFormatInfo.get_InvariantInfo();
 }