Пример #1
0
        private void DepthFirstImpl(XmlNode node)
        {
            OnEnteringNode.RaiseEvent(this, new XmlTraverseEventArgs(node));

            foreach (XmlNode childNode in node.ChildNodes)
            {
                DepthFirstImpl(childNode);
            }

            OnLeavingNode.RaiseEvent(this, new XmlTraverseEventArgs(node));
        }
Пример #2
0
        private void BreadthFirst(XmlNode root)
        {
            Preconditions.NotNull(root, "root");

            var queue = new Queue <XmlNode>();

            queue.Enqueue(root);

            while (queue.Any())
            {
                var node = queue.Dequeue();
                OnEnteringNode.RaiseEvent(this, new XmlTraverseEventArgs(node));

                foreach (XmlNode childNode in node.ChildNodes)
                {
                    queue.Enqueue(childNode);
                }

                OnLeavingNode.RaiseEvent(this, new XmlTraverseEventArgs(node));
            }
        }