Exemple #1
0
            /// <summary>
            ///   Go over all nodes and execute method defined in NodeExecutor
            /// </summary>
            /// <param name = "nodeExecutor">Class implementing NodeExecutor interface</param>
            /// <param name = "level">level in tree</param>
            protected void doForAllNodes(NodeExecutor nodeExecutor, int level)
            {
                //nodeExecutor can change tree, we should remember this in the beginning, QCR #784544
                bool isFirstSibling = (Parent != null && this == Parent.FirstChild || (this == _enclosingInstance._root));

                if (nodeExecutor.Stop)
                {
                    return;
                }
                nodeExecutor.doBeforeChildren(this, level);
                if (FirstChild != null)
                {
                    FirstChild.doForAllNodes(nodeExecutor, level + 1);
                }
                if (nodeExecutor.Stop)
                {
                    return;
                }
                nodeExecutor.doAfterChildren(this, level);
                if (nodeExecutor.Stop)
                {
                    return;
                }
                // if we use recursion for siblings, call stack may explode
                if (isFirstSibling)
                {
                    NodeBase curr = NextSibling;
                    while (curr != null)
                    {
                        if (nodeExecutor.Stop)
                        {
                            return;
                        }
                        curr.doForAllNodes(nodeExecutor, level);
                        curr = curr.NextSibling;
                    }
                }
            }