本文整理汇总了C#中AngleSharp.DOM.Node.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Node.Contains方法的具体用法?C# Node.Contains怎么用?C# Node.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AngleSharp.DOM.Node
的用法示例。
在下文中一共展示了Node.Contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceChild
public virtual Node ReplaceChild(Node newChild, Node oldChild)
{
if (newChild is Attr || newChild is Document || newChild.Contains(this))
throw new DOMException(ErrorCode.HierarchyRequestError);
else if (newChild == oldChild)
return oldChild;
else if (newChild.ParentNode != null)
throw new DOMException(ErrorCode.InUse);
var n = _children.Length;
for (int i = 0; i < n; i++)
{
if (_children[i] == oldChild)
{
RemoveChild(oldChild);
InsertChild(i, newChild);
return oldChild;
}
}
return null;
}
示例2: InsertBefore
public virtual Node InsertBefore(Node newElement, Node referenceElement)
{
if (newElement is Attr || newElement is Document || newElement.Contains(this))
throw new DOMException(ErrorCode.HierarchyRequestError);
var n = _children.Length;
for (int i = 0; i < n; i++)
{
if (_children[i] == referenceElement)
return InsertChild(i, newElement);
}
return AppendChild(newElement);
}
示例3: InsertChild
public virtual Node InsertChild(Int32 index, Node child)
{
if (child is DocumentFragment)
{
var childs = child.ChildNodes;
for (int i = 0; i < childs.Length; i++)
InsertChild(index + i, childs[i]);
}
else if (child is Attr || child is Document || child.Contains(this))
{
throw new DOMException(ErrorCode.HierarchyRequestError);
}
else
{
if (child.ParentNode != null)
throw new DOMException(ErrorCode.InUse);
child._parent = this;
child.OwnerDocument = _owner ?? (this as Document);
_children.Insert(index, child);
}
return child;
}
示例4: CompareDocumentPosition
public virtual DocumentPosition CompareDocumentPosition(Node otherNode)
{
if (this == otherNode)
return DocumentPosition.Same;
if(this.OwnerDocument != otherNode.OwnerDocument)
{
return DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific |
(otherNode.GetHashCode() > this.GetHashCode() ? DocumentPosition.Following : DocumentPosition.Preceding);
}
else if (this.Contains(otherNode))
{
return DocumentPosition.ContainedBy | DocumentPosition.Following;
}
else if (otherNode.Contains(this))
{
return DocumentPosition.Contains | DocumentPosition.Preceding;
}
return CompareRelativePositionInNodeList(_owner.ChildNodes, this, otherNode);
}