예제 #1
0
파일: xmlnode.cs 프로젝트: ydunk/masters
        //the function is provided only at Load time to speed up Load process
        internal virtual XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc)
        {
            XmlNodeChangedEventArgs args = doc.GetInsertEventArgsForLoad(newChild, this);

            if (args != null)
            {
                doc.BeforeEvent(args);
            }

            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (LastNode == null)
            {
                newNode.next = newNode;
            }
            else
            {
                newNode.next  = LastNode.next;
                LastNode.next = newNode;
            }

            LastNode = newNode;
            newNode.SetParentForLoad(this);

            if (args != null)
            {
                doc.AfterEvent(args);
            }

            return(newNode);
        }
예제 #2
0
        internal override XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc)
        {
            XmlNodeChangedEventArgs args = doc.GetInsertEventArgsForLoad(newChild, this);

            if (args != null)
            {
                doc.BeforeEvent(args);
            }

            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (lastChild == null || lastChild == emptyElem)
            {
                newNode.next = newNode;
            }
            else
            {
                newNode.next   = lastChild.next;
                lastChild.next = newNode;
            }

            lastChild = newNode;
            newNode.SetParentForLoad(this);

            if (args != null)
            {
                doc.AfterEvent(args);
            }

            return(newNode);
        }
예제 #3
0
        //the function is provided only at Load time to speed up Load process
        internal override XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc)
        {
            XmlNodeChangedEventArgs?args = doc.GetInsertEventArgsForLoad(newChild, this);

            if (args != null)
            {
                doc.BeforeEvent(args);
            }

            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (_lastChild == null ||
                _lastChild == this)
            {                           // if LastNode == null
                newNode.next = newNode;
                _lastChild   = newNode; // LastNode = newNode;
                newNode.SetParentForLoad(this);
            }
            else
            {
                XmlLinkedNode refNode = _lastChild; // refNode = LastNode;
                newNode.next = refNode.next;
                refNode.next = newNode;
                _lastChild   = newNode; // LastNode = newNode;
                if (refNode.IsText &&
                    newNode.IsText)
                {
                    NestTextNodes(refNode, newNode);
                }
                else
                {
                    newNode.SetParentForLoad(this);
                }
            }

            if (args != null)
            {
                doc.AfterEvent(args);
            }

            return(newNode);
        }
        internal virtual XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc)
        {
            XmlNodeChangedEventArgs insertEventArgsForLoad = doc.GetInsertEventArgsForLoad(newChild, this);

            if (insertEventArgsForLoad != null)
            {
                doc.BeforeEvent(insertEventArgsForLoad);
            }
            XmlLinkedNode lastNode = this.LastNode;
            XmlLinkedNode nextNode = (XmlLinkedNode)newChild;

            if (lastNode == null)
            {
                nextNode.next = nextNode;
                this.LastNode = nextNode;
                nextNode.SetParentForLoad(this);
            }
            else
            {
                nextNode.next = lastNode.next;
                lastNode.next = nextNode;
                this.LastNode = nextNode;
                if (lastNode.IsText && nextNode.IsText)
                {
                    NestTextNodes(lastNode, nextNode);
                }
                else
                {
                    nextNode.SetParentForLoad(this);
                }
            }
            if (insertEventArgsForLoad != null)
            {
                doc.AfterEvent(insertEventArgsForLoad);
            }
            return(nextNode);
        }
예제 #5
0
        internal override XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc)
        {
            Debug.Assert(doc == this);

            if (!IsValidChildType(newChild.NodeType))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_TypeConflict);
            }

            if (!CanInsertAfter(newChild, LastChild))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Location);
            }

            XmlNodeChangedEventArgs args = GetInsertEventArgsForLoad(newChild, this);

            if (args != null)
            {
                BeforeEvent(args);
            }

            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (lastChild == null)
            {
                newNode.next = newNode;
            }
            else
            {
                newNode.next   = lastChild.next;
                lastChild.next = newNode;
            }

            lastChild = newNode;
            newNode.SetParentForLoad(this);

            if (args != null)
            {
                AfterEvent(args);
            }

            return(newNode);
        }