private Selector(string query, Element root) { Validate.NotNull(query); query = query.Trim(); Validate.NotEmpty(query); Validate.NotNull(root); this.evaluator = QueryParser.Parse(query); this.root = root; }
/// <summary> /// Build a list of elements, /// by visiting root and every descendant of root, and testing it against the evaluator. /// </summary> /// <param name="eval">Evaluator to test elements against</param> /// <param name="root">root of tree to descend</param> /// <returns>list of matches; empty if none</returns> public static Elements Collect(Evaluator eval, Element root) { Elements elements = new Elements(); new NodeTraversor(new Collector.Accumulator(root, elements, eval)).Traverse(root); return elements; }
internal Accumulator(Element root, Elements elements, Evaluator eval) { this.root = root; this.elements = elements; this.eval = eval; }
public Parent(Evaluator evaluator) { this.evaluator = evaluator; }
public ImmediateParent(Evaluator evaluator) { this.evaluator = evaluator; }
public ImmediatePreviousSibling(Evaluator evaluator) { this.evaluator = evaluator; }
public Not(Evaluator evaluator) { this.evaluator = evaluator; }
public PreviousSibling(Evaluator evaluator) { this.evaluator = evaluator; }
public Has(Evaluator evaluator) { this.evaluator = evaluator; }
internal void ReplaceRightMostEvaluator(Evaluator replacement) { evaluators[num - 1] = replacement; }
public void Add(Evaluator e) { evaluators.Add(e); UpdateNumEvaluators(); }