System.Windows.Automation.AutomationElement.GetUpdatedCache C# (CSharp) Method

GetUpdatedCache() public method

public GetUpdatedCache ( CacheRequest request ) : AutomationElement
request CacheRequest
return AutomationElement
        public AutomationElement GetUpdatedCache(CacheRequest request)
        {
            try
            {
                return AutomationElement.Wrap(this._obj.BuildUpdatedCache(request.NativeCacheRequest));
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Example #1
0
 public AutomationElement GetUpdatedAEWhenStructureChanged(AutomationElement mainWidow, AutomationPattern patternToCache = null, AutomationProperty propertyToCache = null)
 {
     CacheRequest cacheRequest = new CacheRequest();
     cacheRequest.TreeScope = TreeScope.Element | TreeScope.Descendants | TreeScope.Children;
     cacheRequest.AutomationElementMode = AutomationElementMode.Full;
     cacheRequest.TreeFilter = System.Windows.Automation.Automation.RawViewCondition;
     if (patternToCache != null)
     {
         cacheRequest.Add(patternToCache);
     }
     else
     {
         cacheRequest.Add(SelectionPattern.Pattern);
         cacheRequest.Add(WindowPattern.Pattern);
         cacheRequest.Add(InvokePattern.Pattern);
         cacheRequest.Add(TogglePattern.Pattern);
         cacheRequest.Add(ExpandCollapsePattern.Pattern);
         cacheRequest.Add(ValuePattern.Pattern);
         cacheRequest.Add(SelectionItemPattern.Pattern);
     }
     if (propertyToCache != null)
     {
         cacheRequest.Add(propertyToCache);
     }
     else
     {
         cacheRequest.Add(AutomationElement.NameProperty);
         cacheRequest.Add(AutomationElement.AutomationIdProperty);
         cacheRequest.Add(AutomationElement.ClassNameProperty);
         cacheRequest.Add(AutomationElement.ControlTypeProperty);
     }
     AutomationElement updatedElement;
     using (cacheRequest.Activate())
     {
         updatedElement = mainWidow.GetUpdatedCache(cacheRequest);
     }
     return updatedElement;
 }
All Usage Examples Of System.Windows.Automation.AutomationElement::GetUpdatedCache