private void ReadEndElement() { int num3; base.BufferReader.SkipByte(); XmlBaseReader.XmlElementNode elementNode = base.ElementNode; int nameOffset = elementNode.NameOffset; int nameLength = elementNode.NameLength; byte[] buffer = base.BufferReader.GetBuffer(nameLength, out num3); for (int i = 0; i < nameLength; i++) { if (buffer[num3 + i] != buffer[nameOffset + i]) { this.ReadQualifiedName(this.prefix, this.localName); XmlExceptionHelper.ThrowTagMismatch(this, elementNode.Prefix.GetString(), elementNode.LocalName.GetString(), this.prefix.GetString(), this.localName.GetString()); } } base.BufferReader.Advance(nameLength); if (base.BufferReader.GetByte() != 0x3e) { this.SkipWhitespace(); if (base.BufferReader.GetByte() != 0x3e) { XmlExceptionHelper.ThrowTokenExpected(this, ">", (char)base.BufferReader.GetByte()); } } base.BufferReader.SkipByte(); base.MoveToEndElement(); }
private void ReadCData() { int num; byte[] bytes = base.BufferReader.GetBuffer(7, out num); if ((((bytes[num] != 0x5b) || (bytes[num + 1] != 0x43)) || ((bytes[num + 2] != 0x44) || (bytes[num + 3] != 0x41))) || (((bytes[num + 4] != 0x54) || (bytes[num + 5] != 0x41)) || (bytes[num + 6] != 0x5b))) { XmlExceptionHelper.ThrowTokenExpected(this, "[CDATA[", Encoding.UTF8.GetString(bytes, num, 7)); } base.BufferReader.Advance(7); int offset = base.BufferReader.Offset; Label_007C: switch (base.BufferReader.GetByte()) { case 0x5d: bytes = base.BufferReader.GetBuffer(3, out num); if (((bytes[num] == 0x5d) && (bytes[num + 1] == 0x5d)) && (bytes[num + 2] == 0x3e)) { int length = base.BufferReader.Offset - offset; base.MoveToCData().Value.SetValue(ValueHandleType.UTF8, offset, length); base.BufferReader.Advance(3); return; } base.BufferReader.SkipByte(); goto Label_007C; case 0xef: this.ReadNonFFFE(); goto Label_007C; } base.BufferReader.SkipByte(); goto Label_007C; }
private void ReadComment() { base.BufferReader.SkipByte(); if (base.BufferReader.GetByte() != 0x2d) { XmlExceptionHelper.ThrowTokenExpected(this, "--", (char)base.BufferReader.GetByte()); } base.BufferReader.SkipByte(); int offset = base.BufferReader.Offset; while (true) { byte @byte = base.BufferReader.GetByte(); if (@byte == 0x2d) { int num3; byte[] buffer = base.BufferReader.GetBuffer(3, out num3); if ((buffer[num3] == 0x2d) && (buffer[num3 + 1] == 0x2d)) { if (buffer[num3 + 2] == 0x3e) { break; } XmlExceptionHelper.ThrowXmlException(this, new XmlException(System.Runtime.Serialization.SR.GetString("XmlInvalidCommentChars"))); } base.BufferReader.SkipByte(); } else if ((charType[@byte] & 0x40) == 0) { if (@byte == 0xef) { this.ReadNonFFFE(); } else { XmlExceptionHelper.ThrowInvalidXml(this, @byte); } } else { base.BufferReader.SkipByte(); } } int length = base.BufferReader.Offset - offset; base.MoveToComment().Value.SetValue(ValueHandleType.UTF8, offset, length); base.BufferReader.Advance(3); }
private void ReadDeclaration() { int num; if (!this.buffered) { this.BufferElement(); } byte[] bytes = base.BufferReader.GetBuffer(5, out num); if (((bytes[num] != 0x3f) || (bytes[num + 1] != 120)) || (((bytes[num + 2] != 0x6d) || (bytes[num + 3] != 0x6c)) || ((charType[bytes[num + 4]] & 4) == 0))) { XmlExceptionHelper.ThrowProcessingInstructionNotSupported(this); } if (base.Node.ReadState != System.Xml.ReadState.Initial) { XmlExceptionHelper.ThrowDeclarationNotFirst(this); } base.BufferReader.Advance(5); int offset = num + 1; int length = 3; int num4 = base.BufferReader.Offset; this.SkipWhitespace(); this.ReadAttributes(); int num5 = base.BufferReader.Offset - num4; while (num5 > 0) { byte @byte = base.BufferReader.GetByte((num4 + num5) - 1); if ((charType[@byte] & 4) == 0) { break; } num5--; } bytes = base.BufferReader.GetBuffer(2, out num); if ((bytes[num] != 0x3f) || (bytes[num + 1] != 0x3e)) { XmlExceptionHelper.ThrowTokenExpected(this, "?>", Encoding.UTF8.GetString(bytes, num, 2)); } base.BufferReader.Advance(2); XmlBaseReader.XmlDeclarationNode node = base.MoveToDeclaration(); node.LocalName.SetValue(offset, length); node.Value.SetValue(ValueHandleType.UTF8, num4, num5); }
private void ReadStartElement() { if (!this.buffered) { this.BufferElement(); } XmlBaseReader.XmlElementNode node = base.EnterScope(); node.NameOffset = base.BufferReader.Offset; this.ReadQualifiedName(node.Prefix, node.LocalName); node.NameLength = base.BufferReader.Offset - node.NameOffset; byte @byte = base.BufferReader.GetByte(); while ((charType[@byte] & 4) != 0) { base.BufferReader.SkipByte(); @byte = base.BufferReader.GetByte(); } if ((@byte != 0x3e) && (@byte != 0x2f)) { this.ReadAttributes(); @byte = base.BufferReader.GetByte(); } node.Namespace = base.LookupNamespace(node.Prefix); bool flag = false; if (@byte == 0x2f) { flag = true; base.BufferReader.SkipByte(); } node.IsEmptyElement = flag; node.ExitScope = flag; if (base.BufferReader.GetByte() != 0x3e) { XmlExceptionHelper.ThrowTokenExpected(this, ">", (char)base.BufferReader.GetByte()); } base.BufferReader.SkipByte(); node.BufferOffset = base.BufferReader.Offset; }
private void ReadAttributes() { int num5; int num6; byte[] buffer; XmlBaseReader.XmlAttributeNode node; int num = 0; if (this.buffered) { num = base.BufferReader.Offset; } Label_0016: this.ReadQualifiedName(this.prefix, this.localName); if (base.BufferReader.GetByte() != 0x3d) { this.SkipWhitespace(); if (base.BufferReader.GetByte() != 0x3d) { XmlExceptionHelper.ThrowTokenExpected(this, "=", (char)base.BufferReader.GetByte()); } } base.BufferReader.SkipByte(); byte @byte = base.BufferReader.GetByte(); if ((@byte != 0x22) && (@byte != 0x27)) { this.SkipWhitespace(); @byte = base.BufferReader.GetByte(); if ((@byte != 0x22) && (@byte != 0x27)) { XmlExceptionHelper.ThrowTokenExpected(this, "\"", (char)base.BufferReader.GetByte()); } } base.BufferReader.SkipByte(); bool escaped = false; int offset = base.BufferReader.Offset; Label_00CF: buffer = base.BufferReader.GetBuffer(out num5, out num6); int count = this.ReadAttributeText(buffer, num5, num6); base.BufferReader.Advance(count); byte index = base.BufferReader.GetByte(); if (index != @byte) { if (index == 0x26) { this.ReadCharRef(); escaped = true; } else if ((index == 0x27) || (index == 0x22)) { base.BufferReader.SkipByte(); } else if (((index == 10) || (index == 13)) || (index == 9)) { base.BufferReader.SkipByte(); escaped = true; } else if (index == 0xef) { this.ReadNonFFFE(); } else { XmlExceptionHelper.ThrowTokenExpected(this, ((char)@byte).ToString(), (char)index); } goto Label_00CF; } int length = base.BufferReader.Offset - offset; if (this.prefix.IsXmlns) { XmlBaseReader.Namespace ns = base.AddNamespace(); this.localName.ToPrefixHandle(ns.Prefix); ns.Uri.SetValue(offset, length, escaped); node = base.AddXmlnsAttribute(ns); } else if (this.prefix.IsEmpty && this.localName.IsXmlns) { XmlBaseReader.Namespace namespace3 = base.AddNamespace(); namespace3.Prefix.SetValue(PrefixHandleType.Empty); namespace3.Uri.SetValue(offset, length, escaped); node = base.AddXmlnsAttribute(namespace3); } else if (this.prefix.IsXml) { node = base.AddXmlAttribute(); node.Prefix.SetValue(this.prefix); node.LocalName.SetValue(this.localName); node.Value.SetValue(escaped ? ValueHandleType.EscapedUTF8 : ValueHandleType.UTF8, offset, length); base.FixXmlAttribute(node); } else { node = base.AddAttribute(); node.Prefix.SetValue(this.prefix); node.LocalName.SetValue(this.localName); node.Value.SetValue(escaped ? ValueHandleType.EscapedUTF8 : ValueHandleType.UTF8, offset, length); } node.QuoteChar = (char)@byte; base.BufferReader.SkipByte(); index = base.BufferReader.GetByte(); bool flag2 = false; while ((charType[index] & 4) != 0) { flag2 = true; base.BufferReader.SkipByte(); index = base.BufferReader.GetByte(); } switch (index) { case 0x3e: case 0x2f: case 0x3f: if (this.buffered && ((base.BufferReader.Offset - num) > this.maxBytesPerRead)) { XmlExceptionHelper.ThrowMaxBytesPerReadExceeded(this, this.maxBytesPerRead); } base.ProcessAttributes(); return; } if (!flag2) { XmlExceptionHelper.ThrowXmlException(this, new XmlException(System.Runtime.Serialization.SR.GetString("XmlSpaceBetweenAttributes"))); } goto Label_0016; }