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

DeleteRange() public méthode

public DeleteRange ( XPathNavigator lastSiblingToDelete ) : void
lastSiblingToDelete System.Xml.XPath.XPathNavigator
Résultat void
        public override void DeleteRange(XPathNavigator lastSiblingToDelete) {
            DocumentXPathNavigator that = lastSiblingToDelete as DocumentXPathNavigator;
            if (that == null) {
                if (lastSiblingToDelete == null) {
                    throw new ArgumentNullException("lastSiblingToDelete");
                }
                else {
                    throw new NotSupportedException();
                }
            }

            this.CalibrateText();
            that.CalibrateText();

            XmlNode node = this.source;
            XmlNode end = that.source;

            if (node == end) {
                switch (node.NodeType) {
                    case XmlNodeType.Attribute:
                        XmlAttribute attribute = (XmlAttribute)node;
                        if (attribute.IsNamespace) {
                            goto default;
                        }
                        XmlNode parent = OwnerNode(attribute);
                        DeleteAttribute(attribute, attributeIndex);
                        if (parent != null) {
                            ResetPosition(parent);
                        }
                        break;
                    case XmlNodeType.Text:
                    case XmlNodeType.CDATA:
                    case XmlNodeType.SignificantWhitespace:
                    case XmlNodeType.Whitespace:
                        end = that.TextEnd(end);
                        goto case XmlNodeType.Element;
                    case XmlNodeType.Element:
                    case XmlNodeType.ProcessingInstruction:
                    case XmlNodeType.Comment:
                        parent = OwnerNode(node);
                        DeleteToFollowingSibling(node, end);
                        if (parent != null) {
                            ResetPosition(parent);
                        }
                        break;
                    default:
                        throw new InvalidOperationException(Res.GetString(Res.Xpn_BadPosition));
                }
            }
            else {
                if (end.IsText) {
                    end = that.TextEnd(end);
                }
                if (!IsFollowingSibling(node, end)) {  
                    throw new InvalidOperationException(Res.GetString(Res.Xpn_BadPosition));
                }
                XmlNode parent = OwnerNode(node); 
                DeleteToFollowingSibling(node, end);
                if (parent != null) {
                    ResetPosition(parent);
                }
            }
        }