Ejemplo n.º 1
0
        public Nodewalk NodeWalk(Nodewalk source, INode node, Func <INode, bool> func)
        {
            var result = func(node);

            while (!result && (node.NextSibling != null || node.HasChildNodes))
            {
                if (node.HasChildNodes)
                {
                    foreach (INode child in node.ChildNodes)
                    {
                        var ret = NodeWalk(source, child, func);
                        if (ret.Success)
                        {
                            return(ret);
                        }
                    }
                }
                if (node.NextSibling != null)
                {
                    return(NodeWalk(source, node.NextSibling, func));
                }
                return(new Nodewalk()
                {
                    Success = false, Node = node
                });
            }
            return(new Nodewalk()
            {
                Success = result, Node = node
            });
        }
Ejemplo n.º 2
0
        public Nodewalk NodeWalkBack(Nodewalk source, INode node, Func <INode, bool> func)
        {
            var result = func(node);

            while (!result && (node.PreviousSibling != null || node.ParentElement != null))
            {
                if (node.ParentElement != null)
                {
                    return(NodeWalkBack(source, node.ParentElement, func));
                }
                return(NodeWalkBack(source, node.PreviousSibling, func));
            }
            return(new Nodewalk()
            {
                Success = result, Node = node
            });
        }
Ejemplo n.º 3
0
 public Nodewalk Then(Nodewalk nodeWalk, Func <INode, (bool, INode)> func)