/// <summary> /// Evaluates the specified query. /// </summary> /// <param name="query">The query.</param> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="System.ArgumentOutOfRangeException">query - This evaluator collection have no support for query type [" + query.queryType.ToString() + "]</exception> public NodeQueryResult Evaluate(NodeQueryDefinition query, NodeQueryEvaluationContext context) { NodeQueryResult output = new NodeQueryResult(); if (ContainsKey(query.queryType)) { output = this[query.queryType].EvaluateSingle(query, context); } else { throw new ArgumentOutOfRangeException(nameof(query), "This evaluator collection have no support for query type [" + query.queryType.ToString() + "]"); } return(output); }
/// <summary> /// Evaluates the specified queries. /// </summary> /// <param name="queries">The queries.</param> /// <param name="context">The context.</param> /// <returns></returns> public NodeQueryResult Evaluate(NodeQueryCollection queries, NodeQueryEvaluationContext context) { NodeQueryResult output = null; if (logger != null) { logger.nextTabLevel(); } Log("Query group [" + queries.Count + "]"); Int32 m = 0; foreach (NodeQueryDefinition query in queries) { NodeQueryResult qr = null; if (output != null) { switch (query.relation) { default: case NodeQueryRelation.parallel: break; case NodeQueryRelation.serial: if (output.ResultNodes.Any()) { context = new NodeQueryEvaluationContext() { htmlNodes = new List <HtmlNode>(), documentUrl = context.documentUrl }; context.htmlNodes.AddRange(output.ResultNodes); } break; } } if (query.IsGroupQuery) { qr = Evaluate(query.groupQueries, context); } else { qr = Evaluate(query, context); } if (output == null) { output = qr; } else { m++; String r = output.Merge(qr, query.resultOperand, query.operand); Log(m.ToString("D2") + " { " + r + " } "); } } if (logger != null) { logger.prevTabLevel(); } return(output); }