LookupById() public static method

public static LookupById ( int id ) : AutomationPattern
id int
return AutomationPattern
示例#1
0
        public AutomationPattern[] GetSupportedPatterns()
        {
            int[] patternIds;
            Automation.AutomationClass.PollForPotentialSupportedPatterns(pElement: IUIAutomationElement, patternIds: out patternIds, patternNames: out var _);
            var automationPatternArray = new AutomationPattern[patternIds.Length];

            for (var index = 0; index < patternIds.Length; ++index)
            {
                if (patternIds[index] != 0)
                {
                    try {
                        var automationPattern = AutomationPattern.LookupById(id: patternIds[index]);
                        automationPatternArray[index] = automationPattern;
                    } catch (KeyNotFoundException ex) {
                    }
                }
            }

            return(automationPatternArray);
        }
示例#2
0
        public AutomationPattern[] GetSupportedPatterns()
        {
            Array rawPatternIds;
            Array rawPatternNames;

            try
            {
                Automation.Factory.PollForPotentialSupportedPatterns(this._obj, out rawPatternIds, out rawPatternNames);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
            int[] patternIds = (int[])rawPatternIds;


            // This element may support patterns that are not registered for this
            // client.  Filter them out.
            List <AutomationPattern> patterns = new List <AutomationPattern>();

            foreach (int patternId in patternIds)
            {
                AutomationPattern pattern = AutomationPattern.LookupById(patternId);
                if (pattern != null)
                {
                    patterns.Add(pattern);
                }
            }
            return(patterns.ToArray());
        }