Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public HtmlTree <T> Cast <T>() where T : HtmlNode =>
 HtmlTree.Create((T)(HtmlNode)Node, _ancestorStack);