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

GetNamespacesInScope() private méthode

private GetNamespacesInScope ( XmlNamespaceScope scope ) : string>.IDictionary
scope XmlNamespaceScope
Résultat string>.IDictionary
            internal IDictionary<string,string> GetNamespacesInScope( XmlNamespaceScope scope ) {
                Dictionary<string,string> dict = new Dictionary<string, string>();
                if( this.bCreatedOnAttribute )
                    return dict;

                // walk up the XmlNode parent chain and add all namespace declarations to the dictionary
                XmlNode node = curNode;
                while ( node != null ) {
                    if ( node.NodeType == XmlNodeType.Element ) {
                        XmlElement elem = (XmlElement)node;
                        if ( elem.HasAttributes ) {
                            XmlAttributeCollection attrs = elem.Attributes;
                            for ( int i = 0; i < attrs.Count; i++ ) {
                                XmlAttribute a = attrs[i];
                                if ( a.LocalName == "xmlns" && a.Prefix.Length == 0 ) {
                                    if  ( !dict.ContainsKey( string.Empty ) ) {
                                        dict.Add( nameTable.Add( string.Empty ), nameTable.Add( a.Value ) );
                                    }
                                }
                                else if ( a.Prefix == "xmlns" ) {
                                    string localName = a.LocalName;
                                    if ( !dict.ContainsKey( localName ) ) {
                                        dict.Add( nameTable.Add( localName ), nameTable.Add( a.Value ) );
                                    }
                                }
                            }
                        }
                        if ( scope == XmlNamespaceScope.Local ) {
                            break;
                        }
                    } 
                    else if ( node.NodeType == XmlNodeType.Attribute ) {
                        node = ((XmlAttribute)node).OwnerElement;
                        continue;
                    }
                    node = node.ParentNode;
                };

                if ( scope != XmlNamespaceScope.Local ) {
                    if ( dict.ContainsKey( string.Empty ) && dict[string.Empty] == string.Empty ) {
                        dict.Remove( string.Empty );
                    }
                    if ( scope == XmlNamespaceScope.All ) {
                        dict.Add( nameTable.Add( "xml" ), nameTable.Add( XmlReservedNs.NsXml ) );
                    }
                }
                return dict;
            }