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))); }
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)); } }
public static bool TryParse(string text, out CssSelector result) { return(_TryParse(text, out result) == null); }
protected virtual DomSelector CreateDomSelector(string selector) { return(CssSelector.Parse(selector)); }