System.Xml.DocumentXPathNavigator.MoveToNextNamespace C# (CSharp) Méthode

MoveToNextNamespace() public méthode

public MoveToNextNamespace ( XPathNamespaceScope scope ) : bool
scope XPathNamespaceScope
Résultat bool
        public override bool MoveToNextNamespace(XPathNamespaceScope scope) {
            XmlAttribute attribute = source as XmlAttribute;
            if (attribute == null
                || !attribute.IsNamespace) {
                return false;
            }
            XmlAttributeCollection attributes;
            int index = attributeIndex;
            if (!CheckAttributePosition(attribute, out attributes, index)
                && !ResetAttributePosition(attribute, attributes, out index)) {
                return false;
            }
            Debug.Assert(namespaceParent != null);
            switch (scope) {
                case XPathNamespaceScope.Local:
                    if (attribute.OwnerElement != namespaceParent) {
                        return false;
                    }
                    if (!MoveToNextNamespaceLocal(attributes, ref index)) {
                        return false;
                    }
                    source = attributes[index];
                    attributeIndex = index;
                    break;
                case XPathNamespaceScope.ExcludeXml:
                    string localName;
                    do {
                        if (!MoveToNextNamespaceGlobal(ref attributes, ref index)) {
                            return false;
                        }
                        attribute = attributes[index];
                        localName = attribute.LocalName;
                    }
                    while (PathHasDuplicateNamespace(attribute.OwnerElement, namespaceParent, localName)
                           || Ref.Equals(localName, document.strXml));
                    source = attribute; 
                    attributeIndex = index;
                    break;
                case XPathNamespaceScope.All:
                    do {
                        if (!MoveToNextNamespaceGlobal(ref attributes, ref index)) {
                            if (PathHasDuplicateNamespace(null, namespaceParent, document.strXml)) {
                                return false;
                            }
                            else {
                                source = document.NamespaceXml;
                                // attributeIndex = 0;
                                return true;
                            }
                        }
                        attribute = attributes[index];
                    }
                    while (PathHasDuplicateNamespace(attribute.OwnerElement, namespaceParent, attribute.LocalName));
                    source = attribute;
                    attributeIndex = index;
                    break;
                default:
                    Debug.Assert(false);
                    return false;
            }
            return true;
        }