/// <summary> /// Sets aggregation mode. /// </summary> /// <param name="mode">New aggregation mode.</param> public void SetCollectorMode(QueryCollectionState mode) { _states.Push(_currentState); switch (mode) { case QueryCollectionState.Where: _currentState = new QueryCollectorStateWhere(_aggregator); return; case QueryCollectionState.OrderBy: _currentState = new QueryCollectorStateOrderBy(_aggregator); return; case QueryCollectionState.Select: _currentState = new QueryCollectorStateSelect(_aggregator); return; case QueryCollectionState.GroupBy: _currentState = new QueryCollectorStateGroupBy(_aggregator); return; case QueryCollectionState.Aggregate: _currentState = new QueryCollectorStateAggregation(_aggregator); return; default: throw new InvalidOperationException($"Aggregation mode {mode} is not yet supported by QueryPartCollector."); } }
/// <summary> /// Sets new aggregation mode. /// </summary> public IDisposable PushCollectorMode(QueryCollectionState mode) { LogWriter.WriteLine($"-> PushCollectorMode: {mode}"); SetCollectorMode(mode); return(new DisposeAction(PopCollectorMode)); }