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

MoveToFirstNamespace() public méthode

public MoveToFirstNamespace ( XPathNamespaceScope scope ) : bool
scope XPathNamespaceScope
Résultat bool
        public override bool MoveToFirstNamespace(XPathNamespaceScope scope) {
            XmlElement element = source as XmlElement;
            if (element == null) {
                return false;
            }
            XmlAttributeCollection attributes;
            int index = Int32.MaxValue;
            switch (scope) {
                case XPathNamespaceScope.Local:
                    if (!element.HasAttributes) {
                        return false;
                    }
                    attributes = element.Attributes;
                    if (!MoveToFirstNamespaceLocal(attributes, ref index)) {
                        return false;
                    }
                    source = attributes[index];
                    attributeIndex = index;
                    namespaceParent = element;
                    break;
                case XPathNamespaceScope.ExcludeXml:
                    attributes = element.Attributes;
                    if (!MoveToFirstNamespaceGlobal(ref attributes, ref index)) {
                        return false;
                    }
                    XmlAttribute attribute = attributes[index];
                    while (Ref.Equals(attribute.LocalName, document.strXml)) {
                        if (!MoveToNextNamespaceGlobal(ref attributes, ref index)) {
                            return false;
                        }
                        attribute = attributes[index];
                    }
                    source = attribute;
                    attributeIndex = index;
                    namespaceParent = element;
                    break;
                case XPathNamespaceScope.All:
                    attributes = element.Attributes;
                    if (!MoveToFirstNamespaceGlobal(ref attributes, ref index)) {
                        source = document.NamespaceXml;
                        // attributeIndex = 0;
                    }
                    else {
                        source = attributes[index]; 
                        attributeIndex = index;
                    }
                    namespaceParent = element;
                    break;
                default:
                    Debug.Assert(false);
                    return false;
            }
            return true;
        }