private bool TryEnsureBytes(int count)
        {
            if (this.stream == null)
            {
                return(false);
            }
            if (this.offset > (0x7fffffff - count))
            {
                XmlExceptionHelper.ThrowMaxBytesPerReadExceeded(this.reader, this.windowOffsetMax - this.windowOffset);
            }
            int num = this.offset + count;

            if (num >= this.offsetMax)
            {
                int num3;
                if (num > this.windowOffsetMax)
                {
                    XmlExceptionHelper.ThrowMaxBytesPerReadExceeded(this.reader, this.windowOffsetMax - this.windowOffset);
                }
                if (num > this.buffer.Length)
                {
                    byte[] dst = new byte[Math.Max(num, this.buffer.Length * 2)];
                    System.Buffer.BlockCopy(this.buffer, 0, dst, 0, this.offsetMax);
                    this.buffer       = dst;
                    this.streamBuffer = dst;
                }
                for (int i = num - this.offsetMax; i > 0; i -= num3)
                {
                    num3 = this.stream.Read(this.buffer, this.offsetMax, i);
                    if (num3 == 0)
                    {
                        return(false);
                    }
                    this.offsetMax += num3;
                }
            }
            return(true);
        }
        private bool TryEnsureByte()
        {
            if (this.stream == null)
            {
                return(false);
            }
            if (this.offsetMax >= this.windowOffsetMax)
            {
                XmlExceptionHelper.ThrowMaxBytesPerReadExceeded(this.reader, this.windowOffsetMax - this.windowOffset);
            }
            if (this.offsetMax >= this.buffer.Length)
            {
                return(this.TryEnsureBytes(1));
            }
            int num = this.stream.ReadByte();

            if (num == -1)
            {
                return(false);
            }
            this.buffer[this.offsetMax++] = (byte)num;
            return(true);
        }
        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;
        }