コード例 #1
0
        /// <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.");
            }
        }
コード例 #2
0
        /// <summary>
        /// Restores previous aggregation mode.
        /// </summary>
        public void PopCollectorMode()
        {
            LogWriter.WriteLine($"<- PopCollectorMode");

            if (null == _currentState)
            {
                throw new InvalidOperationException($"Unable to restore previous aggregation mode, history is empty.");
            }

            _currentState.Dispose();
            _currentState = _states.Pop();
        }