public bool TryAs <T>(out HtmlTree <T> tree) where T : HtmlNode { var node = Node as T; tree = node != null ? new HtmlTree <T>(node, _ancestorStack) : default(HtmlTree <T>); return(node != null); }
HtmlTree <HtmlNode>?GetSibling(int offset, Func <int, int, bool> predicate) { if (!HasParent) { return(null); } var siblings = Parent.Value.Node.ChildNodes; var i = siblings.IndexOf(Node); return(predicate(i + offset, siblings.Count) ? HtmlTree.Create(siblings[i + offset], AncestorStack) : (HtmlTree <HtmlNode>?)null); }
public HtmlTree <T> Cast <T>() where T : HtmlNode => HtmlTree.Create((T)(HtmlNode)Node, _ancestorStack);