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