AtspiUiaSource.AutomationSource.IsElementInScope C# (CSharp) Method

IsElementInScope() private static method

private static IsElementInScope ( IElement target, IElement element, TreeScope scope ) : bool
target IElement
element IElement
scope TreeScope
return bool
		private static bool IsElementInScope (IElement target,
		                                       IElement element,
		                                       TreeScope scope)
		{
			IElement e;

			if (target == null)
				return false;

			if ((scope & TreeScope.Element) == TreeScope.Element && target == element)
				return true;

			if ((scope & TreeScope.Children) == TreeScope.Children &&
			    target.Parent == element)
				return true;

			if ((scope & TreeScope.Descendants) == TreeScope.Descendants) {
				e = target.Parent;
				while (e != null) {
					if (e == element)
						return true;
					e = e.Parent;
				}
				if (e == null && element == null)
					return true;
			}

			if (element == null)
				return false;
			e = element.Parent;
			if ((scope & TreeScope.Parent) == TreeScope.Parent &&
			    e != null &&
			    e == target)
				return true;
			if ((scope & TreeScope.Ancestors) == TreeScope.Ancestors) {
				while (e != null) {
					if (e == target)
						return true;
					e = e.Parent;
				}
			}

			return false;
		}