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); }
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()); }