UIAutomation.GetControlCollectionCmdletBase.GetAutomationElementsViaWildcards_FindAll C# (CSharp) Method

GetAutomationElementsViaWildcards_FindAll() private method

private GetAutomationElementsViaWildcards_FindAll ( ControlSearcherData data, IUiElement inputObject, UIANET::System.Windows.Automation conditions, bool caseSensitive, bool onlyOneResult, bool onlyTopLevel, bool viaWildcardOrRegex ) : List
data ControlSearcherData
inputObject IUiElement
conditions UIANET::System.Windows.Automation
caseSensitive bool
onlyOneResult bool
onlyTopLevel bool
viaWildcardOrRegex bool
return List
        internal List<IUiElement> GetAutomationElementsViaWildcards_FindAll(
            ControlSearcherData data,
            IUiElement inputObject,
            classic.Condition conditions,
            bool caseSensitive,
            bool onlyOneResult,
            bool onlyTopLevel,
            bool viaWildcardOrRegex)
        {
            var resultCollection = new List<IUiElement>(); // ? make it null ??
            
            resultCollection =
                GetAutomationElementsWithFindAll(
                    inputObject,
                    data,
                    conditions,
                    caseSensitive,
                    onlyOneResult,
                    onlyTopLevel,
                    viaWildcardOrRegex);
            
            return resultCollection;
        }
        

Usage Example

Example #1
0
        internal void SearchByWildcardViaUIA(
            //GetControlCmdletBase cmdlet,
            //T cmdlet,
            //CommonCmdletBase cmdlet,
            //HasTimeoutCmdletBase cmdlet,
            GetCmdletBase cmdlet,
            ref ArrayList resultCollection,
            AutomationElement inputObject,
            string name,
            string automationId,
            string className,
            string strValue,
            System.Windows.Automation.AndCondition conditionsForWildCards)
        {
            this.WriteVerbose((cmdlet as PSTestLib.PSCmdletBase), "[getting the control] using WildCard search");
            try {
            //                string cmdletValue = string.Empty;
            //                try {
            //                    cmdletValue = cmdlet.Value;
            //                }
            //                catch {}
                // 20130220
                GetControlCollectionCmdletBase cmdlet1 =
                    new GetControlCollectionCmdletBase(
                        //cmdlet.InputObject,
                        null != cmdlet.InputObject ? cmdlet.InputObject : (new AutomationElement[]{ AutomationElement.RootElement }),
                        //null,
                        name, //cmdlet.Name,
                        automationId, //cmdlet.AutomationId,
                        className, //cmdlet.Class,
                        //cmdlet.Value,
                        //string.Empty != cmdlet.Value ? cmdlet.Value : null,
                        strValue,
                        (new string[] {}),
                        this.caseSensitive);
                try {
                    this.WriteVerbose((cmdlet as PSTestLib.PSCmdletBase), "using the GetAutomationElementsViaWildcards_FindAll method");

                    ArrayList tempList =
                        cmdlet1.GetAutomationElementsViaWildcards_FindAll(
                            cmdlet1,
                            inputObject,
                            conditionsForWildCards,
                            cmdlet1.CaseSensitive,
                            false,
                            false);

                    cmdlet.WriteVerbose(
                        cmdlet,
                        "there are " +
                        tempList.Count.ToString() +
                        " elements that match the conditions");

                    foreach (AutomationElement tempElement2 in tempList) {

                        if (null == cmdlet.SearchCriteria || 0 == cmdlet.SearchCriteria.Length) {

                            resultCollection.Add(tempElement2);
                            cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (no SearchCriteria)");
                        } else {

                            cmdlet.WriteVerbose(cmdlet, "WildCardSearch: checking search criteria");
                            if (testControlWithAllSearchCriteria(cmdlet, cmdlet.SearchCriteria, tempElement2)) {

                                cmdlet.WriteVerbose(cmdlet, "WildCardSearch: the control matches the search criteria");
                                resultCollection.Add(tempElement2);
                                cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (SearchCriteria)");
                            }
                            // cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (SearchCriteria) (2)");
                        }
                        // cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (SearchCriteria) (3)");
                    }
                    cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element(s) added to the result collection: " + resultCollection.Count.ToString());
                } catch (Exception eUnexpected) {
                    // this.WriteVerbose(this, eUnexpected.Message);
                    this.WriteError(
                        this,
                        "The input control or window has been possibly lost." +
                        eUnexpected.Message,
                        "UnexpectedError",
                        ErrorCategory.ObjectNotFound,
                        true);
                }
            } catch (Exception eWildCardSearch) {
                this.WriteError(
                    cmdlet,
                    "The input control or window has been possibly lost." +
                    eWildCardSearch.Message,
                    "UnexpectedError",
                    ErrorCategory.ObjectNotFound,
                    true);
            }
        }
All Usage Examples Of UIAutomation.GetControlCollectionCmdletBase::GetAutomationElementsViaWildcards_FindAll