Exemplo n.º 1
0
        public void AddBeforeSelf(HtmlNode content)
        {
            Requires.NotNull(content, nameof(content));

            if (ReferenceEquals(this, content))
            {
                throw new InvalidOperationException("Cannot add a node as before itself.");
            }
            if (ReferenceEquals(this, content.Parent))
            {
                throw new InvalidOperationException("The node has already been added to this node.");
            }
            if (Parent == null)
            {
                throw new InvalidOperationException("This node does not have a parent.");
            }
            AddNodeBefore(Parent, this, content);
        }
Exemplo n.º 2
0
 protected static void AddNodeBefore(HtmlElement parent, HtmlNode nextNode, HtmlNode node)
 {
     node.RemoveFromParent();
     node.Parent = parent;
     parent._nodes.AddBefore(nextNode, node);
 }
Exemplo n.º 3
0
 protected static void AddNodeAfter(HtmlElement parent, HtmlNode previousNode, HtmlNode node)
 {
     node.RemoveFromParent();
     node.Parent = parent;
     parent._nodes.AddAfter(previousNode, node);
 }