public static IValueAsyncPipelineBuilder <TContext> Use <TContext>(this IValueAsyncPipelineBuilder <TContext> builder, Func <TContext, Func <ValueTask>, ValueTask> func) { return(builder.Use(next => context => { return func(context, () => next(context)); })); }
public static IValueAsyncPipelineBuilder <TContext> When <TContext>(this IValueAsyncPipelineBuilder <TContext> builder, Func <TContext, bool> predict, Action <IValueAsyncPipelineBuilder <TContext> > configureAction) { builder.Use((context, next) => { if (predict.Invoke(context)) { var branchPipelineBuilder = builder.New(); configureAction(branchPipelineBuilder); var branchPipeline = branchPipelineBuilder.Build(); return(branchPipeline.Invoke(context)); } return(next()); }); return(builder); }
public static IValueAsyncPipelineBuilder <TContext> Run <TContext>(this IValueAsyncPipelineBuilder <TContext> builder, Func <TContext, ValueTask> handler) { return(builder.Use(_ => handler)); }