/// <summary> /// The depth first visit's implementation. /// </summary> /// <param name="onVisit">A depth first visitor delegate. This is called the first time the node is reached.</param> /// <param name="onLeave">A depth first visitor delegate. This is called after the last child has been visited.</param> private static void DFVImpl(XElement elem, DepthFirstDelegate onVisit, DepthFirstDelegate onLeave) { onVisit(elem); foreach (XElement childElement in elem.Elements()) { DFVImpl(childElement, onVisit, onLeave); } onLeave(elem); }
/// <summary> /// Depth First traversal function used to visit each of the /// differnt elements in a depth first ordering. /// </summary> /// <param name="element">Element which this function is being called on.</param> /// <param name="onVisit">A depth first visitor delegate. This is called the first time the node is reached.</param> /// <param name="onLeave">A depth first visitor delegate. This is called after the last child has been visited.</param> public static void DepthFirstVisit(this XElement element, DepthFirstDelegate onVisit, DepthFirstDelegate onLeave) { DFVImpl(element, onVisit, onLeave); }