Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public static class SelectorExtensions
  2.     {
  3.         /// <summary>
  4.         /// Returns the first element within the given elements (using depth-first
  5.         /// pre-order traversal) that match the selectors with the given scope.
  6.         /// </summary>
  7.         /// <param name="selector">A selector object.</param>
  8.         /// <param name="elements">The elements to take as source.</param>
  9.         /// <param name="scope">The element to take as scope.</param>
  10.         /// <returns>The resulting element or null.</returns>
  11.         public static IElement MatchAny(this ISelector selector, IEnumerable<IElement> elements, IElement scope)
  12.         {
  13.             foreach (var element in elements)
  14.             {
  15.                 foreach (var descendentAndSelf in element.DescendentsAndSelf<IElement>())
  16.                 {
  17.                     if (selector.Match(descendentAndSelf, scope))
  18.                     {
  19.                         return descendentAndSelf;
  20.                     }
  21.                 }
  22.             }
  23.  
  24.             return null;
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement