示例#1
0
 public DomObjectQuery Select(DomSelector selector)
 {
     if (selector == null)
     {
         throw new ArgumentNullException(nameof(selector));
     }
     return(selector.Select(this));
 }
示例#2
0
 public DomObjectQuery Closest(DomSelector selector)
 {
     if (selector == null)
     {
         throw new ArgumentNullException(nameof(selector));
     }
     return(CreateNew(Nodes().Select(e => e.Closest(selector)).NonNull()));
 }
示例#3
0
 public DomContainer Closest(DomSelector selector)
 {
     if (selector == null)
     {
         throw new ArgumentNullException(nameof(selector));
     }
     return((DomContainer)ContainerOrSelf.AncestorsAndSelf.FirstOrDefault(t => selector.Matches(t)));
 }
示例#4
0
        public DomContainer Closest(string selector)
        {
            DomSelector s;

            if (!DomSelector.TryParse(selector, out s))
            {
                throw Failure.NotParsable(nameof(selector), typeof(DomSelector));
            }
            return(Closest(s));
        }
示例#5
0
        private static Exception _TryParse(string text, out DomSelector result)
        {
            result = null;
            if (CssSelector.TryParse(text, out CssSelector css))
            {
                result = css;
                return(null);
            }

            return(Failure.NotParsable("text", typeof(DomSelector)));
        }
示例#6
0
 public DomElement QuerySelector(DomSelector selector)
 {
     return(_items.Select(t => t.QuerySelector(selector)).FirstOrDefault());
 }
示例#7
0
 public DomElementQuery QuerySelectorAll(DomSelector selector)
 {
     return(CreateNew(_items.SelectMany(t => t.QuerySelectorAll(selector))));
 }
示例#8
0
 public DomObjectQuery Select(DomSelector selector)
 {
     return(ProviderFactory.CreateObjectQuery(
                _items.SelectMany(n => n.Select(selector))
                ));
 }
示例#9
0
 public DomElementQuery Closest(DomSelector selector)
 {
     return(Query(e => e.Closest(selector) as DomElement));
 }
示例#10
0
 public DomElement QuerySelector(DomSelector selector)
 {
     return(QuerySelectorAll(selector).FirstOrDefault());
 }
示例#11
0
 public DomElementQuery QuerySelectorAll(DomSelector selector)
 {
     return(Select(selector).Elements);
 }
示例#12
0
 DomNode IDomNodeQuery <DomNode> .Closest(DomSelector selector)
 {
     return(Closest(selector));
 }
示例#13
0
 public static bool TryParse(string text, out DomSelector result)
 {
     return(_TryParse(text, out result) == null);
 }
示例#14
0
 public DomElementQuery QuerySelectorAll(DomSelector selector)
 {
     return(new DomElementQuery(Nodes().SelectMany(t => t.QuerySelectorAll(selector))));
 }
示例#15
0
 public DomObjectQuery Select(DomSelector selector)
 {
     return(CreateNew(
                Nodes().SelectMany(n => n.Select(selector))
                ));
 }
示例#16
0
        public DomObjectQuery Closest(string selector)
        {
            DomSelector s = ParseSelector(selector);

            return(Closest(s));
        }