/// <summary>
        /// Perform a depth-first traversal on each of the selected elements.
        /// </summary>
        /// <param name="nodeVisitor">The visitor callbacks to perform on each node</param>
        /// <returns>This, for chaining</returns>
        public Elements Traverse(NodeVisitor nodeVisitor)
        {
            if (nodeVisitor == null)
            {
                throw new ArgumentNullException("nodeVisitor");
            }
            NodeTraversor traversor = new NodeTraversor(nodeVisitor);

            foreach (Element el in _contents)
            {
                traversor.Traverse(el);
            }
            return(this);
        }
Пример #2
0
        /// <summary>
        /// Perform a depth-first traversal through this node and its descendants.
        /// </summary>
        /// <param name="nodeVisitor">The visitor callbacks to perform on each node</param>
        /// <returns>This node, for chaining</returns>
        public Node Traverse(NodeVisitor nodeVisitor)
        {
            if (nodeVisitor == null)
            {
                throw new ArgumentNullException("nodeVisitor");
            }

            NodeTraversor traversor = new NodeTraversor(nodeVisitor);
            traversor.Traverse(this);
            return this;
        }