public override decimal?ReadAsDecimal()
        {
            decimal num;

            this._readType = JsonTextReader.ReadType.ReadAsDecimal;
            do
            {
                if (this.ReadInternal())
                {
                    continue;
                }
                throw this.CreateJsonReaderException("Unexpected end when reading decimal: Line {0}, position {1}.", new object[] { this._currentLineNumber, this._currentLinePosition });
            }while (this.TokenType == JsonToken.Comment);
            if (this.TokenType == JsonToken.Null)
            {
                return(null);
            }
            if (this.TokenType == JsonToken.Float)
            {
                return((decimal?)this.Value);
            }
            if (this.TokenType != JsonToken.String || !decimal.TryParse((string)this.Value, NumberStyles.Number, this.Culture, out num))
            {
                throw this.CreateJsonReaderException("Unexpected token when reading decimal: {0}. Line {1}, position {2}.", new object[] { this.TokenType, this._currentLineNumber, this._currentLinePosition });
            }
            this.SetToken(JsonToken.Float, num);
            return(new decimal?(num));
        }
        public override DateTimeOffset?ReadAsDateTimeOffset()
        {
            DateTimeOffset dateTimeOffset;

            this._readType = JsonTextReader.ReadType.ReadAsDateTimeOffset;
            do
            {
                if (this.ReadInternal())
                {
                    continue;
                }
                throw this.CreateJsonReaderException("Unexpected end when reading date: Line {0}, position {1}.", new object[] { this._currentLineNumber, this._currentLinePosition });
            }while (this.TokenType == JsonToken.Comment);
            if (this.TokenType == JsonToken.Null)
            {
                return(null);
            }
            if (this.TokenType == JsonToken.Date)
            {
                return(new DateTimeOffset?((DateTimeOffset)this.Value));
            }
            if (this.TokenType != JsonToken.String || !DateTimeOffset.TryParse((string)this.Value, this.Culture, DateTimeStyles.None, out dateTimeOffset))
            {
                throw this.CreateJsonReaderException("Unexpected token when reading date: {0}. Line {1}, position {2}.", new object[] { this.TokenType, this._currentLineNumber, this._currentLinePosition });
            }
            this.SetToken(JsonToken.Date, dateTimeOffset);
            return(new DateTimeOffset?(dateTimeOffset));
        }
        public override byte[] ReadAsBytes()
        {
            this._readType = JsonTextReader.ReadType.ReadAsBytes;
            do
            {
                if (this.ReadInternal())
                {
                    continue;
                }
                throw this.CreateJsonReaderException("Unexpected end when reading bytes: Line {0}, position {1}.", new object[] { this._currentLineNumber, this._currentLinePosition });
            }while (this.TokenType == JsonToken.Comment);
            if (this.TokenType == JsonToken.Null)
            {
                return(null);
            }
            if (this.TokenType == JsonToken.Bytes)
            {
                return((byte[])this.Value);
            }
            if (this.TokenType != JsonToken.StartArray)
            {
                throw this.CreateJsonReaderException("Unexpected token when reading bytes: {0}. Line {1}, position {2}.", new object[] { this.TokenType, this._currentLineNumber, this._currentLinePosition });
            }
            List <byte> nums = new List <byte>();

            while (this.ReadInternal())
            {
                JsonToken tokenType = this.TokenType;
                switch (tokenType)
                {
                case JsonToken.Comment:
                {
                    continue;
                }

                case JsonToken.Integer:
                {
                    nums.Add(Convert.ToByte(this.Value, CultureInfo.InvariantCulture));
                    continue;
                }

                default:
                {
                    if (tokenType == JsonToken.EndArray)
                    {
                        break;
                    }
                    else
                    {
                        throw this.CreateJsonReaderException("Unexpected token when reading bytes: {0}. Line {1}, position {2}.", new object[] { this.TokenType, this._currentLineNumber, this._currentLinePosition });
                    }
                }
                }
                byte[] array = nums.ToArray();
                this.SetToken(JsonToken.Bytes, array);
                return(array);
            }
            throw this.CreateJsonReaderException("Unexpected end when reading bytes: Line {0}, position {1}.", new object[] { this._currentLineNumber, this._currentLinePosition });
        }
 public override bool Read()
 {
     this._readType = JsonTextReader.ReadType.Read;
     return(this.ReadInternal());
 }
        public override byte[] ReadAsBytes()
        {
            this._readType = JsonTextReader.ReadType.ReadAsBytes;
            while (this.ReadInternal())
            {
                if (this.TokenType != JsonToken.Comment)
                {
                    if (this.TokenType == JsonToken.Null)
                    {
                        return(null);
                    }
                    if (this.TokenType == JsonToken.Bytes)
                    {
                        return((byte[])this.Value);
                    }
                    if (this.TokenType == JsonToken.StartArray)
                    {
                        List <byte> list = new List <byte>();
                        while (this.ReadInternal())
                        {
                            JsonToken tokenType = this.TokenType;
                            switch (tokenType)
                            {
                            case JsonToken.Comment:
                                continue;

                            case JsonToken.Raw:
                            {
IL_A6:
                                if (tokenType != JsonToken.EndArray)
                                {
                                    throw this.CreateJsonReaderException("Unexpected token when reading bytes: {0}. Line {1}, position {2}.", new object[]
                                        {
                                            this.TokenType,
                                            this._currentLineNumber,
                                            this._currentLinePosition
                                        });
                                }
                                byte[] array = list.ToArray();
                                this.SetToken(JsonToken.Bytes, array);
                                return(array);
                            }

                            case JsonToken.Integer:
                                list.Add(Convert.ToByte(this.Value, CultureInfo.get_InvariantCulture()));
                                continue;
                            }
                            goto IL_A6;
                        }
                        throw this.CreateJsonReaderException("Unexpected end when reading bytes: Line {0}, position {1}.", new object[]
                        {
                            this._currentLineNumber,
                            this._currentLinePosition
                        });
                    }
                    throw this.CreateJsonReaderException("Unexpected token when reading bytes: {0}. Line {1}, position {2}.", new object[]
                    {
                        this.TokenType,
                        this._currentLineNumber,
                        this._currentLinePosition
                    });
                }
            }
            throw this.CreateJsonReaderException("Unexpected end when reading bytes: Line {0}, position {1}.", new object[]
            {
                this._currentLineNumber,
                this._currentLinePosition
            });
        }