public TResult Aggregate <TResult>(IAggregator <TResult> aggregator, IPredicate predicate) { IsNotNull(aggregator, "aggregator"); IsNotNull(predicate, "predicate"); var request = MapAggregateWithPredicateCodec.EncodeRequest(Name, ToData(aggregator), ToData(predicate)); var response = Invoke(request); var resultParameters = MapAggregateWithPredicateCodec.DecodeResponse(response); return(ToObject <TResult>(resultParameters.Response)); }
private async Task <TResult> AggregateAsync <TResult>(IAggregator <TResult> aggregator, IPredicate predicate, CancellationToken cancellationToken) { var(aggregatorData, predicateData) = ToSafeData(aggregator, predicate); var requestMessage = MapAggregateWithPredicateCodec.EncodeRequest(Name, aggregatorData, predicateData); var responseMessage = await Cluster.Messaging.SendAsync(requestMessage, cancellationToken).CfAwait(); var response = MapAggregateWithPredicateCodec.DecodeResponse(responseMessage).Response; return(ToObject <TResult>(response)); }