public static IEnumerable <T> VisitElements <T>(this XElement source, XElementProjectionFunc <T> func) { foreach (var v in VisitElements(source, func, 0)) { yield return(v); } }
public static IEnumerable <T> VisitElements <T>(XElement source, XElementProjectionFunc <T> func, int depth) { yield return(func(source, depth)); foreach (XElement child in source.Elements()) { foreach (T s in VisitElements(child, func, depth + 1)) { yield return(s); } } }