public IEnumerable <AutomationElement> Find(AutomationElement automationElement, IList <AutomationElement> collection, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(new List <AutomationElement>()); } switch (_xpathAxis) { case XPathAxis.Child: // TODO window if (Name != null && Name.Equals("window", System.StringComparison.InvariantCultureIgnoreCase) && automationElement.Current.ControlType == ControlType.Window) { return(new List <AutomationElement> { automationElement }); } return(new ChildIterator(Name, automationElement, cancellationToken)); case XPathAxis.Descendant: return(new DescendantIterator(automationElement, false, cancellationToken)); case XPathAxis.DescendantOrSelf: return(new DescendantIterator(automationElement, true, cancellationToken)); case XPathAxis.Root: return(new List <AutomationElement> { automationElement }); case XPathAxis.Parent: if (automationElement.CachedParent != null) { return(new List <AutomationElement> { automationElement.CachedParent }); } return(new List <AutomationElement>()); case XPathAxis.Self: return(new List <AutomationElement> { automationElement }); default: throw new System.NotSupportedException(_xpathAxis.ToString()); } }
public XElement Axis(XPathAxis xpathAxis, System.Xml.XPath.XPathNodeType nodeType, string prefix, string name) { return(new XElement(xpathAxis.ToString(), new XAttribute("nodeType", nodeType.ToString()), new XAttribute("prefix", prefix ?? "(null)"), new XAttribute("name", name ?? "(null)") )); }