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


C# INode.Contains方法代码示例

本文整理汇总了C#中INode.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# INode.Contains方法的具体用法?C# INode.Contains怎么用?C# INode.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在INode的用法示例。


在下文中一共展示了INode.Contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefaultReplaceChild

        /// <summary>
        /// Replaces one child node of the specified element with another.
        /// </summary>
        /// <param name="newChild">The new node to replace oldChild. If it already exists in the DOM, it is first removed.</param>
        /// <param name="oldChild">The existing child to be replaced.</param>
        /// <returns>The replaced node. This is the same node as oldChild.</returns>
        protected INode DefaultReplaceChild(INode newChild, INode oldChild)
        {
            if (oldChild == null || newChild == null)
                return null;

            if (newChild is IDocument || newChild.Contains(this))
                throw new DomException(ErrorCode.HierarchyRequest);
            else if (newChild == oldChild)
                return oldChild;
            else if (newChild.Parent != null)
                throw new DomException(ErrorCode.InUse);

            var n = _children.Length;

            for (int i = 0; i < n; i++)
            {
                if (_children[i] == oldChild)
                {
                    DefaultRemoveChild(oldChild);
                    DefaultInsertChild(i, newChild);
                    return oldChild;
                }
            }

            return null;
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:32,代码来源:Node.cs

示例2: DefaultInsertBefore

        /// <summary>
        /// Inserts the specified node before a reference element as a child of the current node.
        /// </summary>
        /// <param name="newElement">The node to insert.</param>
        /// <param name="referenceElement">The node before which newElement is inserted. If
        /// referenceElement is null, newElement is inserted at the end of the list of child nodes.</param>
        /// <returns>The inserted node.</returns>
        protected INode DefaultInsertBefore(INode newElement, INode referenceElement)
        {
            if (newElement == null || referenceElement == null)
                return null;

            if (newElement is IDocument || newElement.Contains(this))
                throw new DomException(ErrorCode.HierarchyRequest);

            var n = _children.Length;

            for (int i = 0; i < n; i++)
            {
                if (_children[i] == referenceElement)
                    return DefaultInsertChild(i, newElement);
            }

            return DefaultAppendChild(newElement);
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:25,代码来源:Node.cs

示例3: DefaultInsertChild

        /// <summary>
        /// Inserts a child to the collection of children at the specified index.
        /// </summary>
        /// <param name="index">The index where to insert.</param>
        /// <param name="child">The child to insert.</param>
        /// <returns>The inserted child.</returns>
        protected INode DefaultInsertChild(Int32 index, INode child)
        {
            if (child == null)
                return null;

            if (child is IDocumentFragment)
            {
                while (child.HasChilds)
                    DefaultInsertChild(index++, child.RemoveChild(child.FirstChild));
            }
            else if (child is IDocument || child.Contains(this))
            {
                throw new DomException(ErrorCode.HierarchyRequest);
            }
            else
            {
                if (child.Parent != null)
                    throw new DomException(ErrorCode.InUse);

                var childNode = child as Node;

                if (childNode != null)
                {
                    childNode.Parent = this;
                    childNode.Owner = _owner ?? (this as Document);
                    _children.Insert(index, childNode);
                }
            }

            return child;
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:37,代码来源:Node.cs

示例4: CompareDocumentPosition

        /// <summary>
        /// Compares the position of the current node against another node in any other document.
        /// </summary>
        /// <param name="otherNode">The node that's being compared against.</param>
        /// <returns>The relationship that otherNode has with node, given in a bitmask.</returns>
        public virtual DocumentPositions CompareDocumentPosition(INode otherNode)
        {
            if (this == otherNode)
                return DocumentPositions.Same;

            if (_owner != otherNode.Owner)
                return DocumentPositions.Disconnected | DocumentPositions.ImplementationSpecific | (otherNode.GetHashCode() > GetHashCode() ? DocumentPositions.Following : DocumentPositions.Preceding);
            else if (Contains(otherNode))
                return DocumentPositions.ContainedBy | DocumentPositions.Following;
            else if (otherNode.Contains(this))
                return DocumentPositions.Contains | DocumentPositions.Preceding;

            return CompareRelativePositionInNodeList(_owner.ChildNodes, this, otherNode);
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:19,代码来源:Node.cs


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