public JsonTextReader(TextReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     this._reader = new BufferedCharReader(reader);
     this.Push(this.ParseMethod);
 }
 protected override JsonToken ReadTokenImpl()
 {
     if (this._stack == null)
     {
         return JsonToken.EOF();
     }
     if (this._stack.Count == 0)
     {
         this._stack = null;
         this._reader = null;
         return JsonToken.EOF();
     }
     return this.Pop()();
 }
Exemple #3
0
        internal static StringBuilder Dequote(BufferedCharReader input, char quote, StringBuilder output)
        {
            char ch;
            if (output == null)
            {
                output = new StringBuilder();
            }
            char[] hexDigits = null;
        Label_000C:
            ch = input.Next();
            switch (ch)
            {
                case '\0':
                case '\n':
                case '\r':
                    throw new FormatException("Unterminated string.");

                default:
                    if (ch != '\\')
                    {
                        if (ch == quote)
                        {
                            return output;
                        }
                        output.Append(ch);
                        goto Label_000C;
                    }
                    ch = input.Next();
                    switch (ch)
                    {
                        case 'r':
                            output.Append('\r');
                            goto Label_000C;

                        case 't':
                            output.Append('\t');
                            goto Label_000C;

                        case 'u':
                            if (hexDigits == null)
                            {
                                hexDigits = new char[4];
                            }
                            output.Append(ParseHex(input, hexDigits));
                            goto Label_000C;

                        case 'n':
                            output.Append('\n');
                            goto Label_000C;

                        case 'b':
                            output.Append('\b');
                            goto Label_000C;

                        case 'f':
                            output.Append('\f');
                            goto Label_000C;
                    }
                    break;
            }
            output.Append(ch);
            goto Label_000C;
        }
Exemple #4
0
 private static char ParseHex(BufferedCharReader input, char[] hexDigits)
 {
     hexDigits[0] = input.Next();
     hexDigits[1] = input.Next();
     hexDigits[2] = input.Next();
     hexDigits[3] = input.Next();
     return (char) ushort.Parse(new string(hexDigits), NumberStyles.HexNumber);
 }
Exemple #5
0
 internal static string Dequote(BufferedCharReader input, char quote)
 {
     return Dequote(input, quote, null).ToString();
 }