private void ResetState() { this.complexTextMode = XmlJsonReader.JsonComplexTextMode.None; this.expectingFirstElementInNonPrimitiveChild = false; this.charactersToSkipOnNextRead = new byte[2]; this.scopeDepth = 0; if (this.scopes == null || this.scopes.Length <= 25) return; this.scopes = (JsonNodeType[])null; }
private void ReadNumericalText() { int offset; int offsetMax; int num; if (this.buffered) { num = XmlJsonReader.ComputeNumericalTextLength(this.BufferReader.GetBuffer(out offset, out offsetMax), offset, offsetMax); } else { byte[] buffer = this.BufferReader.GetBuffer(2048, out offset, out offsetMax); int numericalTextLength = XmlJsonReader.ComputeNumericalTextLength(buffer, offset, offsetMax); num = XmlJsonReader.BreakText(buffer, offset, numericalTextLength); } this.BufferReader.Advance(num); if (offset <= offsetMax - num) { this.MoveToAtomicText().Value.SetValue(ValueHandleType.UTF8, offset, num); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.None; } else { this.MoveToComplexText().Value.SetValue(ValueHandleType.UTF8, offset, num); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.NumericalText; } }
private void ReadQuotedText(bool moveToText) { int offset; int offsetMax; bool escaped; int num; if (this.buffered) { num = XmlJsonReader.ComputeQuotedTextLengthUntilEndQuote(this.BufferReader.GetBuffer(out offset, out offsetMax), offset, offsetMax, out escaped); } else { byte[] buffer = this.BufferReader.GetBuffer(2048, out offset, out offsetMax); int lengthUntilEndQuote = XmlJsonReader.ComputeQuotedTextLengthUntilEndQuote(buffer, offset, offsetMax, out escaped); num = XmlJsonReader.BreakText(buffer, offset, lengthUntilEndQuote); } if (escaped && (int)this.BufferReader.GetByte() == 239) { offset = this.BufferReader.Offset; num = this.ReadNonFFFE(); } this.BufferReader.Advance(num); if (!escaped && offset < offsetMax - num) { if (moveToText) this.MoveToAtomicText().Value.SetValue(ValueHandleType.UTF8, offset, num); this.SkipExpectedByteInBufferReader((byte)34); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.None; } else if (num == 0 && escaped) { this.ReadEscapedCharacter(moveToText); } else { if (moveToText) this.MoveToComplexText().Value.SetValue(ValueHandleType.UTF8, offset, num); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.QuotedText; } }
private void ReadEscapedCharacter(bool moveToText) { this.BufferReader.SkipByte(); char ch1 = (char)this.BufferReader.GetByte(); if ((int)ch1 == 117) { this.BufferReader.SkipByte(); int offset; byte[] buffer = this.BufferReader.GetBuffer(5, out offset); string string1 = Encoding.UTF8.GetString(buffer, offset, 4); this.BufferReader.Advance(4); int ch2 = (int)XmlJsonReader.ParseChar(string1, NumberStyles.HexNumber); if (char.IsHighSurrogate((char)ch2) && (int)this.BufferReader.GetByte() == 92) { this.BufferReader.SkipByte(); this.SkipExpectedByteInBufferReader((byte)117); buffer = this.BufferReader.GetBuffer(5, out offset); string string2 = Encoding.UTF8.GetString(buffer, offset, 4); this.BufferReader.Advance(4); char ch3 = XmlJsonReader.ParseChar(string2, NumberStyles.HexNumber); if (!char.IsLowSurrogate(ch3)) XmlExceptionHelper.ThrowXmlException((XmlDictionaryReader)this, new XmlException(System.Runtime.Serialization.SR.GetString("XmlInvalidLowSurrogate", new object[1] { (object) string2 }))); ch2 = new SurrogateChar(ch3, (char)ch2).Char; } if ((int)buffer[offset + 4] == 34) { this.BufferReader.SkipByte(); if (moveToText) this.MoveToAtomicText().Value.SetCharValue(ch2); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.None; } else { if (moveToText) this.MoveToComplexText().Value.SetCharValue(ch2); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.QuotedText; } } else { switch (ch1) { case 'n': ch1 = '\n'; goto case '"'; case 'r': ch1 = '\r'; goto case '"'; case 't': ch1 = '\t'; goto case '"'; case 'b': ch1 = '\b'; goto case '"'; case 'f': ch1 = '\f'; goto case '"'; case '"': case '/': case '\\': this.BufferReader.SkipByte(); if ((int)this.BufferReader.GetByte() == 34) { this.BufferReader.SkipByte(); if (moveToText) this.MoveToAtomicText().Value.SetCharValue((int)ch1); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.None; break; } else { if (moveToText) this.MoveToComplexText().Value.SetCharValue((int)ch1); this.complexTextMode = XmlJsonReader.JsonComplexTextMode.QuotedText; break; } default: // ISSUE: reference to a compiler-generated method XmlExceptionHelper.ThrowXmlException((XmlDictionaryReader)this, new XmlException(SR2.GetString(SR2.JsonEncounteredUnexpectedCharacter, new object[1] { (object) ch1 }))); goto case '"'; } } }