/// <summary> /// Get Element based on Scope /// if Scope is Element, returns the current element /// if Scope is App, find out App element and return the App element /// </summary> /// <param name="e"></param> /// <returns></returns> protected A11yElement GetElementBasedOnScope(A11yElement e) { if (e != null && Scope == SelectionScope.App) { var el = A11yAutomation.GetAppElement(e); // if the original selection is Top most element of the app, it should not be released. if (e != el) { e.Dispose(); } return(el); } return(e); }
/// <summary> /// Set element for Next selection call /// it is for internal use. /// </summary> /// <param name="el"></param> public void SetCandidateElement(A11yElement el) { lock (this) { if (el != null) { if (el.IsRootElement() == false) { this.CandidateEC?.Dispose(); this.CandidateEC = new ElementContext(el); } else { el.Dispose(); } } } }