System.Xml.XmlAttributeCollection.InsertAfter C# (CSharp) Méthode

InsertAfter() public méthode

public InsertAfter ( XmlAttribute newNode, XmlAttribute refNode ) : XmlAttribute
newNode XmlAttribute
refNode XmlAttribute
Résultat XmlAttribute
        public XmlAttribute InsertAfter( XmlAttribute newNode, XmlAttribute refNode ) {
            if ( newNode == refNode )
                return newNode;

            if (refNode == null)
                return Prepend(newNode);

            if (refNode.OwnerElement != parent)
                throw new ArgumentException(Res.GetString(Res.Xdom_AttrCol_Insert));

            if (newNode.OwnerDocument != null && newNode.OwnerDocument != parent.OwnerDocument)
                throw new ArgumentException(Res.GetString(Res.Xdom_NamedNode_Context));

            if (newNode.OwnerElement != null)
                Detach( newNode );

            int offset = FindNodeOffset( refNode.LocalName, refNode.NamespaceURI );
            Debug.Assert( offset != -1 ); // the if statement above guarantees that the ref node is in the collection

            int dupoff = RemoveDuplicateAttribute( newNode );
            if ( dupoff >= 0 && dupoff < offset )
                offset--;
            InsertNodeAt( offset+1, newNode );

            return newNode;
        }