Esempio n. 1
0
        /// <summary>
        /// Inserts new HTML elements specified by the given HTML string at a
        /// position relative to the current element specified by the position.
        /// </summary>
        /// <param name="position">The relation to the current element.</param>
        /// <param name="html">The HTML code to generate elements for.</param>
        public void Insert(AdjacentPosition position, String html)
        {
            var useThis    = position == AdjacentPosition.BeforeBegin || position == AdjacentPosition.AfterEnd;
            var nodeParent = useThis ? this : Parent as Element;
            var nodes      = new DocumentFragment(nodeParent, html);

            switch (position)
            {
            case AdjacentPosition.BeforeBegin:
                Parent.InsertBefore(nodes, this);
                break;

            case AdjacentPosition.AfterEnd:
                Parent.InsertChild(Parent.IndexOf(this) + 1, nodes);
                break;

            case AdjacentPosition.AfterBegin:
                InsertChild(0, nodes);
                break;

            case AdjacentPosition.BeforeEnd:
                AppendChild(nodes);
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a duplicate of the node on which this method was called.
        /// </summary>
        /// <param name="deep">
        /// Optional value: true if the children of the node should also be
        /// cloned, or false to clone only the specified node.
        /// </param>
        /// <returns>The duplicate node.</returns>
        public override INode Clone(Boolean deep = true)
        {
            var node = new DocumentFragment(Owner);

            CopyProperties(this, node, deep);
            return(node);
        }
        public override INode Clone(Boolean deep = true)
        {
            var node = new DocumentFragment(Owner);

            CloneNode(node, deep);
            return(node);
        }
Esempio n. 4
0
        public override Node Clone(Document owner, Boolean deep)
        {
            var node = new DocumentFragment(owner);

            CloneNode(node, owner, deep);
            return(node);
        }
Esempio n. 5
0
        public void Insert(AdjacentPosition position, String html)
        {
            var useThis = position == AdjacentPosition.AfterBegin || position == AdjacentPosition.BeforeEnd;
            var context = useThis ? this : Parent as Element;

            if (context == null)
            {
                throw new DomException("The element has no parent.");
            }

            var nodes = new DocumentFragment(context, html);

            switch (position)
            {
            case AdjacentPosition.BeforeBegin:
                Parent.InsertBefore(nodes, this);
                break;

            case AdjacentPosition.AfterEnd:
                Parent.InsertChild(Parent.IndexOf(this) + 1, nodes);
                break;

            case AdjacentPosition.AfterBegin:
                InsertChild(0, nodes);
                break;

            case AdjacentPosition.BeforeEnd:
                AppendChild(nodes);
                break;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Inserts new HTML elements specified by the given HTML string at a
        /// position relative to the current element specified by the position.
        /// </summary>
        /// <param name="position">The relation to the current element.</param>
        /// <param name="html">The HTML code to generate elements for.</param>
        public void Insert(AdjacentPosition position, String html)
        {
            var useThis = position == AdjacentPosition.BeforeBegin || position == AdjacentPosition.AfterEnd;
            var nodeParent = useThis ? this : Parent as Element;
            var nodes = new DocumentFragment(nodeParent, html);

            switch (position)
            {
                case AdjacentPosition.BeforeBegin:
                    Parent.InsertBefore(nodes, this);
                    break;

                case AdjacentPosition.AfterEnd:
                    Parent.InsertChild(Parent.IndexOf(this) + 1, nodes);
                    break;

                case AdjacentPosition.AfterBegin:
                    InsertChild(0, nodes);
                    break;

                case AdjacentPosition.BeforeEnd:
                    AppendChild(nodes);
                    break;
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Returns a duplicate of the node on which this method was called.
 /// </summary>
 /// <param name="deep">
 /// Optional value: true if the children of the node should also be
 /// cloned, or false to clone only the specified node.
 /// </param>
 /// <returns>The duplicate node.</returns>
 public override INode Clone(Boolean deep = true)
 {
     var node = new DocumentFragment(Owner);
     CopyProperties(this, node, deep);
     return node;
 }
Esempio n. 8
0
 public override INode Clone(Boolean deep = true)
 {
     var node = new DocumentFragment(Owner);
     CloneNode(node, deep);
     return node;
 }