|
1 | | -namespace Hyperbee.Pipeline.Binders; |
| 1 | +using Hyperbee.Pipeline.Binders.Abstractions; |
2 | 2 |
|
3 | | -internal class CallBlockBinder<TInput, TOutput> |
4 | | -{ |
5 | | - private FunctionAsync<TInput, TOutput> Pipeline { get; } |
6 | | - private Function<TOutput, bool> Condition { get; } |
| 3 | +namespace Hyperbee.Pipeline.Binders; |
7 | 4 |
|
| 5 | +internal class CallBlockBinder<TInput, TOutput> : BlockBinder<TInput, TOutput> |
| 6 | +{ |
8 | 7 | public CallBlockBinder( FunctionAsync<TInput, TOutput> function ) |
9 | | - : this( null, function ) |
10 | | - { |
11 | | - } |
12 | | - |
13 | | - public CallBlockBinder( Function<TOutput, bool> condition, FunctionAsync<TInput, TOutput> function ) |
| 8 | + : base( function, default ) |
14 | 9 | { |
15 | | - Condition = condition; |
16 | | - Pipeline = function; |
17 | 10 | } |
18 | 11 |
|
19 | 12 | public FunctionAsync<TInput, TOutput> Bind( FunctionAsync<TOutput, object> next ) |
20 | 13 | { |
21 | 14 | return async ( context, argument ) => |
22 | 15 | { |
23 | | - var nextArgument = await Pipeline( context, argument ).ConfigureAwait( false ); |
| 16 | + var (nextArgument, canceled) = await ProcessPipelineAsync( context, argument ).ConfigureAwait( false ); |
24 | 17 |
|
25 | | - if ( Condition == null || Condition( context, nextArgument ) ) |
26 | | - await next( context, nextArgument ).ConfigureAwait( false ); |
| 18 | + if ( canceled ) |
| 19 | + return default; |
27 | 20 |
|
| 21 | + await ProcessBlockAsync( next, context, nextArgument ).ConfigureAwait( false ); |
28 | 22 | return nextArgument; |
29 | 23 | }; |
30 | 24 | } |
|
0 commit comments