Exemple #1
0
		/// <summary>
		/// This will insert a node at the given position
		/// </summary>
		/// <param name="index">The position at which to insert the node.</param>
		/// <param name="node">The node to insert.</param>
		public void Insert(int index,HtmlNode node)
		{
			if( mParent != null ) node.SetParent( mParent );
			base.InnerList.Insert( index , node );
		}
Exemple #2
0
		/// <summary>
		/// This is used to identify the index of this node as it appears in the collection.
		/// </summary>
		/// <param name="node">The node to test</param>
		/// <returns>The index of the node, or -1 if it is not in this collection</returns>
		public int IndexOf(HtmlNode node)
		{
			return base.List.IndexOf( node );
		}
Exemple #3
0
		/// <summary>
		/// This will add a node to the collection.
		/// </summary>
		/// <param name="node"></param>
		/// <returns></returns>
		public int Add(HtmlNode node)
		{
			if( mParent != null ) node.SetParent( mParent );
			return base.List.Add( node );
		}
Exemple #4
0
		public HtmlNode GetCommonAncestor(HtmlNode node)
		{
			HtmlNode thisParent = this;
			while( thisParent != null )
			{
				HtmlNode thatParent = node;
				while( thatParent != null )
				{
					if( thisParent == thatParent )
					{
						return thisParent;
					}
					thatParent = thatParent.Parent;
				}
				thisParent = thisParent.Parent;
			}
			return null;
		}
Exemple #5
0
		public bool IsAncestorOf(HtmlNode node)
		{
			return node.IsDescendentOf( this );
		}
Exemple #6
0
		public bool IsDescendentOf(HtmlNode node)
		{
			HtmlNode parent = mParent;
			while( parent != null )
			{
				if( parent == node )
				{
					return true;
				}
				parent = parent.Parent;
			}
			return false;
		}