HtmlAgilityPack.HtmlNode.CloseNode C# (CSharp) Method

CloseNode() private method

private CloseNode ( HtmlNode endnode ) : void
endnode HtmlNode
return void
		internal void CloseNode(HtmlNode endnode)
		{
			if (!_ownerdocument.OptionAutoCloseOnEnd)
			{
				// close all children
				if (_childnodes != null)
				{
					foreach(HtmlNode child in _childnodes)
					{
						if (child.Closed)
							continue;

						// create a fake closer node
						HtmlNode close = new HtmlNode(NodeType, _ownerdocument, -1);
						close._endnode = close;
						child.CloseNode(close);
					}
				}
			}

			if (!Closed)
			{
				_endnode = endnode;

				if (_ownerdocument._openednodes != null)
				{
					_ownerdocument._openednodes.Remove(_outerstartindex);
				}

				HtmlNode self = _ownerdocument._lastnodes[Name] as HtmlNode;
				if (self == this)
				{
					_ownerdocument._lastnodes.Remove(Name);
					_ownerdocument.UpdateLastParentNode();
				}

				if (endnode == this)
					return;

				// create an inner section
				_innerstartindex = _outerstartindex + _outerlength;
				_innerlength = endnode._outerstartindex - _innerstartindex;

				// update full length
				_outerlength = (endnode._outerstartindex + endnode._outerlength) - _outerstartindex;
			}
		}