/// <summary>
        /// Initializes all pattern objects within the property grid with the AutomationElement patterns supported
        /// </summary>
        public AutomationElementPropertyObject(AutomationElement automationElement)
        {
            this.AutomationElement = automationElement;

            foreach (AutomationPattern patternId in automationElement.GetSupportedPatterns())
            {
                object pattern = null;
                if (false == automationElement.TryGetCurrentPattern(patternId, out pattern))
                {
                    continue;
                }

                if (pattern is DockPattern)
                {
                    this._dockPatternPropertyObject = new DockPatternPropertyObject((DockPattern)pattern);
                }
                else if (pattern is ExpandCollapsePattern)
                {
                    this._expandCollapsePatternPropertyObject = new ExpandCollapsePatternPropertyObject((ExpandCollapsePattern)pattern);
                }
                else if (pattern is GridPattern)
                {
                    this._gridPatternPropertyObject = new GridPatternPropertyObject((GridPattern)pattern);
                }
                else if (pattern is InvokePattern)
                {
                    this._invokePatternPropertyObject = new InvokePatternPropertyObject((InvokePattern)pattern);
                }
                else if (pattern is MultipleViewPattern)
                {
                    this._multipleViewPatternPropertyObject = new MultipleViewPatternPropertyObject((MultipleViewPattern)pattern);
                }
                else if (pattern is RangeValuePattern)
                {
                    this._rangeValuePatternPropertyObject = new RangeValuePatternPropertyObject((RangeValuePattern)pattern);
                }
                else if (pattern is ScrollItemPattern)
                {
                    this._scrollItemPatternPropertyObject = new ScrollItemPatternPropertyObject((ScrollItemPattern)pattern);
                }
                else if (pattern is ScrollPattern)
                {
                    this._scrollPatternPropertyObject = new ScrollPatternPropertyObject((ScrollPattern)pattern);
                }
                else if (pattern is SelectionItemPattern)
                {
                    this._selectionItemPatternPropertyObject = new SelectionItemPatternPropertyObject((SelectionItemPattern)pattern);
                }
                else if (pattern is SelectionPattern)
                {
                    this._selectionPatternPropertyObject = new SelectionPatternPropertyObject((SelectionPattern)pattern);
                }
                else if (pattern is TableItemPattern)
                {
                    this._tableItemPatternPropertyObject = new TableItemPatternPropertyObject((TableItemPattern)pattern);
                }
                else if (pattern is TablePattern)
                {
                    this._tablePatternPropertyObject = new TablePatternPropertyObject((TablePattern)pattern);
                }
                else if (pattern is TextPattern)
                {
                    this._textPatternPropertyObject = new TextPatternPropertyObject((TextPattern)pattern);
                }
                else if (pattern is TogglePattern)
                {
                    this._togglePatternPropertyObject = new TogglePatternPropertyObject((TogglePattern)pattern);
                }
                else if (pattern is TransformPattern)
                {
                    this._transformPatternPropertyObject = new TransformPatternPropertyObject((TransformPattern)pattern);
                }
                else if (pattern is ValuePattern)
                {
                    this._valuePatternPropertyObject = new ValuePatternPropertyObject((ValuePattern)pattern);
                }
                else if (pattern is WindowPattern)
                {
                    this._windowPatternPropertyObject = new WindowPatternPropertyObject((WindowPattern)pattern);
                }
            }
        }
        /// <summary>
        /// Initializes all pattern objects within the property grid with the AutomationElement patterns supported
        /// </summary>
        public AutomationElementPropertyObject(AutomationElement automationElement)
        {
            this.AutomationElement = automationElement;

            // fill in the common patterns from plugins, so that they're present even if not implemented
            _commonPatternDescriptorObjects = PluginLoader.CommonPatternDescriptors.ToDictionary(d => d.DisplayName, _ => (object)null);

            foreach (AutomationPattern patternId in automationElement.GetSupportedPatterns())
            {
                object pattern = null;
                if (false == automationElement.TryGetCurrentPattern(patternId, out pattern))
                {
                    continue;
                }

                if (pattern is DockPattern)
                {
                    this._dockPatternPropertyObject = new DockPatternPropertyObject((DockPattern)pattern);
                }
                else if (pattern is ExpandCollapsePattern)
                {
                    this._expandCollapsePatternPropertyObject = new ExpandCollapsePatternPropertyObject((ExpandCollapsePattern)pattern);
                }
                else if (pattern is TablePattern)
                {
                    this._tablePatternPropertyObject = new TablePatternPropertyObject((TablePattern)pattern);
                }
                else if (pattern is GridPattern)
                {
                    this._gridPatternPropertyObject = new GridPatternPropertyObject((GridPattern)pattern);
                }
                else if (pattern is InvokePattern)
                {
                    this._invokePatternPropertyObject = new InvokePatternPropertyObject((InvokePattern)pattern);
                }
                else if (pattern is MultipleViewPattern)
                {
                    this._multipleViewPatternPropertyObject = new MultipleViewPatternPropertyObject((MultipleViewPattern)pattern);
                }
                else if (pattern is RangeValuePattern)
                {
                    this._rangeValuePatternPropertyObject = new RangeValuePatternPropertyObject((RangeValuePattern)pattern);
                }
                else if (pattern is ScrollItemPattern)
                {
                    this._scrollItemPatternPropertyObject = new ScrollItemPatternPropertyObject((ScrollItemPattern)pattern);
                }
                else if (pattern is ScrollPattern)
                {
                    this._scrollPatternPropertyObject = new ScrollPatternPropertyObject((ScrollPattern)pattern);
                }
                else if (pattern is SelectionItemPattern)
                {
                    this._selectionItemPatternPropertyObject = new SelectionItemPatternPropertyObject((SelectionItemPattern)pattern);
                }
                else if (pattern is SelectionPattern)
                {
                    this._selectionPatternPropertyObject = new SelectionPatternPropertyObject((SelectionPattern)pattern);
                }
                else if (pattern is TableItemPattern)
                {
                    this._tableItemPatternPropertyObject = new TableItemPatternPropertyObject((TableItemPattern)pattern);
                }
                else if (pattern is TextPattern)
                {
                    this._textPatternPropertyObject = new TextPatternPropertyObject((TextPattern)pattern);
                }
                else if (pattern is TogglePattern)
                {
                    this._togglePatternPropertyObject = new TogglePatternPropertyObject((TogglePattern)pattern);
                }
                else if (pattern is TransformPattern)
                {
                    this._transformPatternPropertyObject = new TransformPatternPropertyObject((TransformPattern)pattern);
                }
                else if (pattern is ValuePattern)
                {
                    this._valuePatternPropertyObject = new ValuePatternPropertyObject((ValuePattern)pattern);
                }
                else if (pattern is WindowPattern)
                {
                    this._windowPatternPropertyObject = new WindowPatternPropertyObject((WindowPattern)pattern);
                }

                IUiaVerifyPatternDescriptor patternDesc;
                if (PluginLoader.PatternDescriptorMap.TryGetValue(patternId.Id, out patternDesc))
                {
                    object patternDescriptorObject;
                    if (!patternDesc.TryGetPatternInstanceDescribingObject(pattern, out patternDescriptorObject))
                    {
                        continue;
                    }
                    var targetDict = patternDesc.IsCommon
                                         ? _commonPatternDescriptorObjects
                                         : _customPatternDescriptorObjects;
                    targetDict[patternDesc.DisplayName] = patternDescriptorObject;
                }
            }
        }