当前位置: 首页>>代码示例>>C#>>正文


C# Node.Contains方法代码示例

本文整理汇总了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;
        }
开发者ID:rrsc,项目名称:AngleSharp,代码行数:23,代码来源:Node.cs

示例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);
        }
开发者ID:rrsc,项目名称:AngleSharp,代码行数:15,代码来源:Node.cs

示例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;
        }
开发者ID:rrsc,项目名称:AngleSharp,代码行数:25,代码来源:Node.cs

示例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);
        }
开发者ID:rrsc,项目名称:AngleSharp,代码行数:21,代码来源:Node.cs


注:本文中的AngleSharp.DOM.Node.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。