LookupById() 공개 정적인 메소드

public static LookupById ( int id ) : AutomationPattern
id int
리턴 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());
        }