Exemplo n.º 1
0
                public static TryCatch <AggregateValue> TryCreate(
                    AggregateOperator aggregateOperator,
                    string continuationToken)
                {
                    TryCatch <IAggregator> tryCreateAggregator;

                    switch (aggregateOperator)
                    {
                    case AggregateOperator.Average:
                        tryCreateAggregator = AverageAggregator.TryCreate(continuationToken);
                        break;

                    case AggregateOperator.Count:
                        tryCreateAggregator = CountAggregator.TryCreate(continuationToken);
                        break;

                    case AggregateOperator.Max:
                        tryCreateAggregator = MinMaxAggregator.TryCreateMaxAggregator(continuationToken);
                        break;

                    case AggregateOperator.Min:
                        tryCreateAggregator = MinMaxAggregator.TryCreateMinAggregator(continuationToken);
                        break;

                    case AggregateOperator.Sum:
                        tryCreateAggregator = SumAggregator.TryCreate(continuationToken);
                        break;

                    default:
                        throw new ArgumentException($"Unknown {nameof(AggregateOperator)}: {aggregateOperator}.");
                    }

                    return(tryCreateAggregator.Try <AggregateValue>((aggregator) => new AggregateAggregateValue(aggregator)));
                }
                public static AggregateAggregateValue Create(
                    AggregateOperator aggregateOperator,
                    string continuationToken)
                {
                    IAggregator aggregator;

                    switch (aggregateOperator)
                    {
                    case AggregateOperator.Average:
                        aggregator = AverageAggregator.Create(continuationToken);
                        break;

                    case AggregateOperator.Count:
                        aggregator = CountAggregator.Create(continuationToken);
                        break;

                    case AggregateOperator.Max:
                        aggregator = MinMaxAggregator.CreateMaxAggregator(continuationToken);
                        break;

                    case AggregateOperator.Min:
                        aggregator = MinMaxAggregator.CreateMinAggregator(continuationToken);
                        break;

                    case AggregateOperator.Sum:
                        aggregator = SumAggregator.Create(continuationToken);
                        break;

                    default:
                        throw new ArgumentException($"Unknown {nameof(AggregateOperator)}: {aggregateOperator}.");
                    }

                    return(new AggregateAggregateValue(aggregator));
                }