Пример #1
0
 public void Initialize(QueryEngine <TData> engine, QueryGraph graph, ICollection <QueryError> errors, bool fastYielding)
 {
     if (graph != null && !graph.empty)
     {
         m_QueryEnumerable = EnumerableCreator.Create(graph.root, engine, errors, fastYielding);
     }
 }
Пример #2
0
        public IQueryEnumerable <T> Create <T>(IQueryNode root, QueryEngine <T> engine, ICollection <QueryError> errors, bool fastYielding)
        {
            if (root.leaf || root.children == null || root.children.Count != 1)
            {
                errors.Add(new QueryError(root.token.position, root.token.length, "Aggregator node must have a child."));
                return(null);
            }

            var aggregatorNode = root as AggregatorNode;

            if (!(aggregatorNode?.aggregator is NestedQueryAggregator <T> handler))
            {
                errors.Add(new QueryError(root.token.position, root.token.length, "Aggregator node does not have the proper aggregator set."));
                return(null);
            }
            var childEnumerable = EnumerableCreator.Create(root.children[0], engine, errors, fastYielding);

            return(new AggregateEnumerable <T>(childEnumerable, handler.aggregator, fastYielding));
        }