예제 #1
0
                public async Task <Terminator <TReduction> > CompleteAsync(TReduction reduction)
                {
                    var terminator = await Next.CompleteAsync(reduction).ConfigureAwait(false);

                    var terminated = CheckTermination(terminator);

                    return(Reduction(terminator.Value, terminated: terminated));
                }
예제 #2
0
        public static async Task <Terminator <TReduction> > ReduceAsync <TInput, TReduction>(
            this IEnumerable <TInput> input,
            TReduction reduction,
            IAsyncReducer <TReduction, TInput> reducer)
        {
            var terminator = Terminator.Reduction(reduction);

            foreach (var value in input)
            {
                terminator = await reducer.InvokeAsync(terminator.Value, value).ConfigureAwait(false);

                if (terminator.IsTerminated)
                {
                    return(terminator);
                }
            }

            return(await reducer.CompleteAsync(terminator.Value).ConfigureAwait(false));
        }
예제 #3
0
 public Task <Terminator <TReduction> > CompleteAsync(TReduction reduction) => Next.CompleteAsync(reduction);