public static TryCatch <AggregateValue> TryCreate( AggregateOperator aggregateOperator, CosmosElement 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))); }