Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class SelectorExtensions
- {
- /// <summary>
- /// Returns the first element within the given elements (using depth-first
- /// pre-order traversal) that match the selectors with the given scope.
- /// </summary>
- /// <param name="selector">A selector object.</param>
- /// <param name="elements">The elements to take as source.</param>
- /// <param name="scope">The element to take as scope.</param>
- /// <returns>The resulting element or null.</returns>
- public static IElement MatchAny(this ISelector selector, IEnumerable<IElement> elements, IElement scope)
- {
- foreach (var element in elements)
- {
- foreach (var descendentAndSelf in element.DescendentsAndSelf<IElement>())
- {
- if (selector.Match(descendentAndSelf, scope))
- {
- return descendentAndSelf;
- }
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement