Exemplo n.º 1
0
        public AggregationStateFactory MakeFactory()
        {
            var sortUsingCollator  = _methodResolutionService.IsSortUsingCollator;
            var comparator         = CollectionUtil.GetComparator(_evaluators, sortUsingCollator, _sortDescending);
            var criteriaKeyBinding = _methodResolutionService.GetCriteriaKeyBinding(_evaluators);

            AggregationStateFactory factory;

            if (_ever)
            {
                var spec = new AggregationStateMinMaxByEverSpec(_streamNum, _evaluators, _parent.IsMax, comparator, criteriaKeyBinding);
                factory = new ProxyAggregationStateFactory()
                {
                    ProcCreateAccess          = (methodResolutionService, agentInstanceId, groupId, aggregationId, join, groupKey) => methodResolutionService.MakeAccessAggMinMaxEver(agentInstanceId, groupId, aggregationId, spec),
                    ProcAggregationExpression = () => _parent,
                };
            }
            else
            {
                var spec = new AggregationStateSortedSpec(_streamNum, _evaluators, comparator, criteriaKeyBinding);
                factory = new ProxyAggregationStateFactory()
                {
                    ProcCreateAccess = (methodResolutionService, agentInstanceId, groupId, aggregationId, join, groupKey) => {
                        if (join)
                        {
                            return(methodResolutionService.MakeAccessAggSortedJoin(agentInstanceId, groupId, aggregationId, spec));
                        }
                        return(methodResolutionService.MakeAccessAggSortedNonJoin(agentInstanceId, groupId, aggregationId, spec));
                    },

                    ProcAggregationExpression = () => _parent,
                };
            }
            return(factory);
        }