Exemplo n.º 1
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)));
        }
Exemplo n.º 2
0
        private static Exception _TryParse(string text, out CssSelector result)
        {
            result = null;
            if (text == null)
            {
                return(new ArgumentNullException(nameof(text)));
            }

            text = text.Trim();
            if (text.Length == 0)
            {
                return(Failure.AllWhitespace(nameof(text)));
            }

            try {
                var opts      = new QueryParserOptions();
                var evaluator = QueryParser.Parse(text, opts);
                result = new CssSelector(evaluator);
                return(null);
            } catch (Exception ex) {
                return(Failure.NotParsable(nameof(text), typeof(CssSelector), ex));
            }
        }
Exemplo n.º 3
0
 public static bool TryParse(string text, out CssSelector result)
 {
     return(_TryParse(text, out result) == null);
 }
Exemplo n.º 4
0
 protected virtual DomSelector CreateDomSelector(string selector)
 {
     return(CssSelector.Parse(selector));
 }