public virtual int IndexOfLocalName(
            XmlDictionaryString [] localNames,
            XmlDictionaryString namespaceUri)
        {
            if (localNames == null)
            {
                throw new ArgumentNullException("localNames");
            }
            if (namespaceUri == null)
            {
                throw new ArgumentNullException("namespaceUri");
            }
            if (NamespaceURI != namespaceUri.Value)
            {
                return(-1);
            }
            XmlDictionaryString localName;

            if (!TryGetLocalNameAsDictionaryString(out localName))
            {
                return(-1);
            }
            IXmlDictionary      dict = localName.Dictionary;
            XmlDictionaryString iter;

            for (int i = 0; i < localNames.Length; i++)
            {
                if (dict.TryLookup(localNames [i], out iter) && object.ReferenceEquals(iter, localName))
                {
                    return(i);
                }
            }
            return(-1);
        }
Beispiel #2
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 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);
            }
        }
 private XmlDictionaryString LookupDictionaryString(IXmlDictionary dictionary, string value)
 {
     XmlDictionaryString str;
     if (!dictionary.TryLookup(value, out str))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(System.IdentityModel.SR.GetString("XDCannotFindValueInDictionaryString", new object[] { value }));
     }
     return str;
 }
Beispiel #5
0
        private XmlDictionaryString LookupDictionaryString(IXmlDictionary dictionary, string value)
        {
            XmlDictionaryString str;

            if (!dictionary.TryLookup(value, out str))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(System.IdentityModel.SR.GetString("XDCannotFindValueInDictionaryString", new object[] { value }));
            }
            return(str);
        }
Beispiel #6
0
        private XmlDictionaryString LookupDictionaryString(
            IXmlDictionary dictionary,
            string value)
        {
            XmlDictionaryString result;

            if (!dictionary.TryLookup(value, out result))
            {
                throw new ArgumentException("XDCannotFindValueInDictionaryString");
            }
            return(result);
        }
Beispiel #7
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));
        }
Beispiel #8
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);
        }
Beispiel #9
0
        XmlDictionaryString LookupDictionaryString(IXmlDictionary dictionary, string value)
        {
            XmlDictionaryString expectedValue;
            if (!dictionary.TryLookup(value, out expectedValue))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.XDCannotFindValueInDictionaryString, value));

            return expectedValue;
        }