private static void doFind(Control target, ICollection <Control> result, ControlSieve matches, bool recursive, bool stopAtFirst) { if (target == null || !target.HasControls()) { return; } foreach (Control c in target.Controls) { if (stopAtFirst && result.Count > 0) { break; } if (matches(c)) { result.Add(c); if (stopAtFirst) { break; } } if (recursive) { doFind(c, result, matches, true, stopAtFirst); } } }
private static void doFind(Control target, ICollection<Control> result, ControlSieve matches, bool recursive, bool stopAtFirst) { if (target == null || !target.HasControls()) return; foreach (Control c in target.Controls) { if (stopAtFirst && result.Count > 0) break; if (matches(c)) { result.Add(c); if (stopAtFirst) break; } if (recursive) { doFind(c, result, matches, true, stopAtFirst); } } }