private void VerifyNCName(string s)
 {
     try
     {
         XmlConvert.VerifyNCName(s);
     }
     catch (XmlException exception)
     {
         XmlExceptionHelper.ThrowXmlException(this, exception);
     }
 }
        private void ReadNonFFFE()
        {
            int num;

            byte[] buffer = base.BufferReader.GetBuffer(3, out num);
            if ((buffer[num + 1] == 0xbf) && ((buffer[num + 2] == 190) || (buffer[num + 2] == 0xbf)))
            {
                XmlExceptionHelper.ThrowXmlException(this, new XmlException(System.Runtime.Serialization.SR.GetString("XmlInvalidFFFE")));
            }
            base.BufferReader.Advance(3);
        }
        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 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;
        }
        public override bool Read()
        {
            if (base.Node.ReadState == System.Xml.ReadState.Closed)
            {
                return(false);
            }
            if (base.Node.CanMoveToElement)
            {
                this.MoveToElement();
            }
            base.SignNode();
            if (base.Node.ExitScope)
            {
                base.ExitScope();
            }
            if (!this.buffered)
            {
                base.BufferReader.SetWindow(base.ElementNode.BufferOffset, this.maxBytesPerRead);
            }
            if (base.BufferReader.EndOfFile)
            {
                base.MoveToEndOfFile();
                return(false);
            }
            byte @byte = base.BufferReader.GetByte();

            if (@byte == 60)
            {
                base.BufferReader.SkipByte();
                @byte = base.BufferReader.GetByte();
                switch (@byte)
                {
                case 0x2f:
                    this.ReadEndElement();
                    goto Label_025B;

                case 0x21:
                    base.BufferReader.SkipByte();
                    if (base.BufferReader.GetByte() == 0x2d)
                    {
                        this.ReadComment();
                    }
                    else
                    {
                        if (base.OutsideRootElement)
                        {
                            XmlExceptionHelper.ThrowXmlException(this, new XmlException(System.Runtime.Serialization.SR.GetString("XmlCDATAInvalidAtTopLevel")));
                        }
                        this.ReadCData();
                    }
                    goto Label_025B;

                case 0x3f:
                    this.ReadDeclaration();
                    break;
                }
                if (@byte == 0x3f)
                {
                    this.ReadDeclaration();
                }
                else
                {
                    this.ReadStartElement();
                }
            }
            else if ((charType[@byte] & 0x20) != 0)
            {
                this.ReadWhitespace();
            }
            else if (base.OutsideRootElement && (@byte != 13))
            {
                XmlExceptionHelper.ThrowInvalidRootData(this);
            }
            else if ((charType[@byte] & 8) != 0)
            {
                this.ReadText();
            }
            else if (@byte == 0x26)
            {
                this.ReadEscapedText();
            }
            else if (@byte == 13)
            {
                base.BufferReader.SkipByte();
                if (!base.BufferReader.EndOfFile && (base.BufferReader.GetByte() == 10))
                {
                    this.ReadWhitespace();
                }
                else
                {
                    base.MoveToComplexText().Value.SetCharValue(10);
                }
            }
            else if (@byte == 0x5d)
            {
                int    num2;
                byte[] buffer = base.BufferReader.GetBuffer(3, out num2);
                if (((buffer[num2] == 0x5d) && (buffer[num2 + 1] == 0x5d)) && (buffer[num2 + 2] == 0x3e))
                {
                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(System.Runtime.Serialization.SR.GetString("XmlCloseCData")));
                }
                base.BufferReader.SkipByte();
                base.MoveToComplexText().Value.SetCharValue(0x5d);
            }
            else if (@byte == 0xef)
            {
                int offset = base.BufferReader.Offset;
                this.ReadNonFFFE();
                base.MoveToComplexText().Value.SetValue(ValueHandleType.UTF8, offset, 3);
            }
            else
            {
                XmlExceptionHelper.ThrowInvalidXml(this, @byte);
            }
Label_025B:
            return(true);
        }