Automation.UI.Tree.SearchEngines.TreeWalkerSearchEngine.ExecuteWithChildren C# (CSharp) Method

ExecuteWithChildren() private static method

Calls the specified callback for each child of the specified node.
private static ExecuteWithChildren ( AutomationElement root, WithElementCallback callback ) : object
root System.Windows.Automation.AutomationElement The root element.
callback WithElementCallback The callback.
return object
        private static object ExecuteWithChildren(AutomationElement root, WithElementCallback callback)
        {
            var children = root.FindAll(TreeScope.Children, Condition.TrueCondition);
            // Iterate over all the children and call the callback with each one.
            // Return the first call that returns a non-null value.
            foreach (AutomationElement child in children) {
                var result = callback(child);
                if (result != null)
                    return result;
            }
            // None of the calls returned a value, so return the default value.
            return null;
        }