System.Xml.DocumentSchemaValidator.GetNamespacesInScope C# (CSharp) Méthode

GetNamespacesInScope() public méthode

public GetNamespacesInScope ( XmlNamespaceScope scope ) : string>.IDictionary
scope XmlNamespaceScope
Résultat string>.IDictionary
        public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
        {
            IDictionary<string, string> dictionary = _nsManager.GetNamespacesInScope(scope);
            if (scope != XmlNamespaceScope.Local)
            {
                XmlNode node = _startNode;
                while (node != null)
                {
                    switch (node.NodeType)
                    {
                        case XmlNodeType.Element:
                            XmlElement elem = (XmlElement)node;
                            if (elem.HasAttributes)
                            {
                                XmlAttributeCollection attrs = elem.Attributes;
                                for (int i = 0; i < attrs.Count; i++)
                                {
                                    XmlAttribute attr = attrs[i];
                                    if (Ref.Equal(attr.NamespaceURI, _document.strReservedXmlns))
                                    {
                                        if (attr.Prefix.Length == 0)
                                        {
                                            // xmlns='' declaration
                                            if (!dictionary.ContainsKey(string.Empty))
                                            {
                                                dictionary.Add(string.Empty, attr.Value);
                                            }
                                        }
                                        else
                                        {
                                            // xmlns:prefix='' declaration
                                            if (!dictionary.ContainsKey(attr.LocalName))
                                            {
                                                dictionary.Add(attr.LocalName, attr.Value);
                                            }
                                        }
                                    }
                                }
                            }
                            node = node.ParentNode;
                            break;
                        case XmlNodeType.Attribute:
                            node = ((XmlAttribute)node).OwnerElement;
                            break;
                        default:
                            node = node.ParentNode;
                            break;
                    }
                }
            }
            return dictionary;
        }