TryLookup() public method

public TryLookup ( System value, System &result ) : bool
value System
result System
return bool
Ejemplo n.º 1
0
        public string GetValue(IXmlDictionary staticDictionary, XmlBinaryReaderSession readerSession)
        {
            int id = this.DictionaryId / 2;
            XmlDictionaryString dicString = XmlDictionaryString.Empty;
            bool found;
            if (this.IsSession)
            {
                if (readerSession == null)
                {
                    return null;
                }

                found = readerSession.TryLookup(id, out dicString);
            }
            else
            {
                if (staticDictionary == null)
                {
                    return null;
                }

                found = staticDictionary.TryLookup(id, out dicString);
            }

            if (found)
            {
                return dicString.Value;
            }
            else
            {
                throw new ArgumentException("Cannot find value for dictionary string with ID = " + this.DictionaryId);
            }
        }
        public XmlDictionaryString GetDictionaryString(int key)
        {
            IXmlDictionary      session;
            XmlDictionaryString str;

            if ((key & 1) != 0)
            {
                session = this.session;
            }
            else
            {
                session = this.dictionary;
            }
            if (!session.TryLookup((int)(key >> 1), out str))
            {
                XmlExceptionHelper.ThrowInvalidBinaryFormat(this.reader);
            }
            return(str);
        }
Ejemplo n.º 3
0
        private XmlDictionaryString ReadDictName()
        {
            int key = ReadVariantSize();
            XmlDictionaryString s;

            if ((key & 1) == 1)
            {
                if (session.TryLookup(key >> 1, out s))
                {
                    return(s);
                }
            }
            else
            {
                if (dictionary.TryLookup(key >> 1, out s))
                {
                    return(s);
                }
            }
            throw new XmlException(String.Format("Input XML binary stream is invalid. No matching XML dictionary string entry at {0}. Binary stream position at {1}", key, source.Position));
        }
Ejemplo n.º 4
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);
        }