Exemplo n.º 1
0
        public int ReadDictionaryKey()
        {
            int key = ReadMultiByteUInt31();

            if ((key & 1) != 0)
            {
                if (_session == null)
                {
                    XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader);
                }
                int sessionKey = (key >> 1);
                XmlDictionaryString xmlString;
                if (!_session.TryLookup(sessionKey, out xmlString))
                {
                    if (sessionKey < XmlDictionaryString.MinKey || sessionKey > XmlDictionaryString.MaxKey)
                    {
                        XmlExceptionHelper.ThrowXmlDictionaryStringIDOutOfRange(_reader);
                    }
                    XmlExceptionHelper.ThrowXmlDictionaryStringIDUndefinedSession(_reader, sessionKey);
                }
            }
            else
            {
                if (_dictionary == null)
                {
                    XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader);
                }
                int staticKey = (key >> 1);
                XmlDictionaryString xmlString;
                if (!_dictionary.TryLookup(staticKey, out xmlString))
                {
                    if (staticKey < XmlDictionaryString.MinKey || staticKey > XmlDictionaryString.MaxKey)
                    {
                        XmlExceptionHelper.ThrowXmlDictionaryStringIDOutOfRange(_reader);
                    }
                    XmlExceptionHelper.ThrowXmlDictionaryStringIDUndefinedStatic(_reader, staticKey);
                }
            }
            return(key);
        }
        public int ReadDictionaryKey()
        {
            XmlDictionaryString str2;
            int num = this.ReadMultiByteUInt31();

            if ((num & 1) != 0)
            {
                XmlDictionaryString str;
                if (this.session == null)
                {
                    XmlExceptionHelper.ThrowInvalidBinaryFormat(this.reader);
                }
                int num2 = num >> 1;
                if (!this.session.TryLookup(num2, out str))
                {
                    if ((num2 < 0) || (num2 > 0x1fffffff))
                    {
                        XmlExceptionHelper.ThrowXmlDictionaryStringIDOutOfRange(this.reader);
                    }
                    XmlExceptionHelper.ThrowXmlDictionaryStringIDUndefinedSession(this.reader, num2);
                }
                return(num);
            }
            if (this.dictionary == null)
            {
                XmlExceptionHelper.ThrowInvalidBinaryFormat(this.reader);
            }
            int key = num >> 1;

            if (!this.dictionary.TryLookup(key, out str2))
            {
                if ((key < 0) || (key > 0x1fffffff))
                {
                    XmlExceptionHelper.ThrowXmlDictionaryStringIDOutOfRange(this.reader);
                }
                XmlExceptionHelper.ThrowXmlDictionaryStringIDUndefinedStatic(this.reader, key);
            }
            return(num);
        }