public static VisualObject GetChild(VisualObject rootObject, Expression <Func <VisualObject, bool> > filter) { if (rootObject == null) { return((VisualObject)null); } if (filter.Compile()(rootObject)) { return(rootObject); } IEnumerable <VisualObject> visualChildren = rootObject.GetVisualChildren(); if (visualChildren == null) { return((VisualObject)null); } foreach (VisualObject rootObject1 in visualChildren) { VisualObject child = VisualObjectHelper.GetChild(rootObject1, filter); if (child != null) { return(child); } } return((VisualObject)null); }
public static VisualObject GetChild(VisualObject rootObject, Expression <Func <VisualObject, bool> > filter) { VisualObject result; if (rootObject == null) { result = null; } else if (filter.Compile()(rootObject)) { result = rootObject; } else { IEnumerable <VisualObject> visualChildren = rootObject.GetVisualChildren(); if (visualChildren == null) { result = null; } else { foreach (VisualObject current in visualChildren) { VisualObject child = VisualObjectHelper.GetChild(current, filter); if (child != null) { result = child; return(result); } } result = null; } } return(result); }