コード例 #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;
            }
        }
コード例 #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);
        }
コード例 #3
0
        public override INode Clone(Boolean deep = true)
        {
            var node = new DocumentFragment(Owner);

            CloneNode(node, deep);
            return(node);
        }
コード例 #4
0
        public override Node Clone(Document owner, Boolean deep)
        {
            var node = new DocumentFragment(owner);

            CloneNode(node, owner, deep);
            return(node);
        }
コード例 #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;
            }
        }
コード例 #6
0
ファイル: Element.cs プロジェクト: sparra/AngleSharp
        /// <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;
            }
        }
コード例 #7
0
ファイル: ShadowRoot.cs プロジェクト: fjwuyongzhi/AngleSharp
 /// <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;
 }
コード例 #8
0
ファイル: DocumentFragment.cs プロジェクト: Wojdav/AngleSharp
 public override INode Clone(Boolean deep = true)
 {
     var node = new DocumentFragment(Owner);
     CloneNode(node, deep);
     return node;
 }