Пример #1
0
        public XmlName GetName(string prefix, string localName, string ns)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }
            if (ns == null)
            {
                ns = string.Empty;
            }

            int hashCode = XmlNameHelper.GetHashCode(localName);

            for (XmlName e = entries[hashCode & mask]; e != null; e = e.next)
            {
                if (e.HashCode == hashCode &&
                    ((object)e.LocalName == (object)localName ||
                     e.LocalName.Equals(localName)) &&
                    ((object)e.Prefix == (object)prefix ||
                     e.Prefix.Equals(prefix)) &&
                    ((object)e.NamespaceURI == (object)ns ||
                     e.NamespaceURI.Equals(ns)))
                {
                    return(e);
                }
            }
            return(null);
        }
Пример #2
0
        public XmlName AddName(string prefix, string localName, string ns)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }
            if (ns == null)
            {
                ns = string.Empty;
            }

            int hashCode = XmlNameHelper.GetHashCode(localName);

            for (XmlName e = entries[hashCode & mask]; e != null; e = e.next)
            {
                if (e.HashCode == hashCode &&
                    ((object)e.LocalName == (object)localName ||
                     e.LocalName.Equals(localName)) &&
                    ((object)e.Prefix == (object)prefix ||
                     e.Prefix.Equals(prefix)) &&
                    ((object)e.NamespaceURI == (object)ns ||
                     e.NamespaceURI.Equals(ns)))
                {
                    return(e);
                }
            }

            prefix    = nameTable.Add(prefix);
            localName = nameTable.Add(localName);
            ns        = nameTable.Add(ns);
            int     index = hashCode & mask;
            XmlName name  = XmlName.Create(prefix, localName, ns, hashCode, ownerDocument, entries[index]);

            entries[index] = name;

            if (count++ == mask)
            {
                Grow();
            }

            return(name);
        }
Пример #3
0
        public XmlAttribute this[string name]
        {
            get
            {
                int hash = XmlNameHelper.GetHashCode(name);

                for (int i = 0; i < nodes.Count; i++)
                {
                    XmlAttribute node = (XmlAttribute)nodes[i];

                    if (hash == node.LocalNameHash &&
                        name == node.Name)
                    {
                        return(node);
                    }
                }

                return(null);
            }
        }