/// <summary> /// Populate element with list of properties /// </summary> /// <param name="element"></param> /// <param name="list"></param> private static void PopulateWithIndicatedProperties(this A11yElement element, List <int> list) { element.Clear(); if (element.IsSafeToRefresh()) { A11yAutomation.UIAutomationObject.PollForPotentialSupportedProperties((IUIAutomationElement)element.PlatformObject, out int[] ppids, out string[] ppns); // build a cache based on the lists var cache = DesktopElementHelper.BuildCacheRequest(list, null); // buildupdate cached element var uia = ((IUIAutomationElement)element.PlatformObject).BuildUpdatedCache(cache); var properties = RetrievePropertiesFromCache(uia, list); element.Properties = properties.Where(p => !string.IsNullOrEmpty(p.TextValue)).ToDictionary(d => d.Id); element.UpdateGlimpse(); // release previous UIAElement Marshal.ReleaseComObject(uia); // release cache interface. Marshal.ReleaseComObject(cache); } }
/// <summary> /// Populate member data and testresults are cleaned up. /// if there is existing data, clean up first and populate /// please don't call it directly but use UpdateElementAction. /// it would make Ux and Runtime separation easier since all communication is done via Actions. /// </summary> /// <param name="element"></param> public static void PopulateAllPropertiesWithLiveData(this A11yElement element) { element.Clear(); if (element.IsSafeToRefresh()) { element.PopulatePropertiesAndPatternsFromCache(); element.PopulatePlatformProperties(); } }
/// <summary> /// Populate member data and testresults are cleaned up. /// if there is existing data, clean up first and populate /// please don't call it directly but use UpdateElementAction. /// it would make Ux and Runtime separation easier since all communication is done via Actions. /// </summary> /// <param name="element"></param> public static void PopulateAllPropertiesWithLiveData(this A11yElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); element.Clear(); if (element.IsSafeToRefresh()) { element.PopulatePropertiesAndPatternsFromCache(); element.PopulatePlatformProperties(); } }