// Choose public static VoidSyncMiddleware <TContext> Choose <TContext>( this IEnumerable <VoidSyncMiddleware <TContext> > choices, Func <TContext, bool> wasChosen, VoidSyncMiddleware <TContext> defaultAction) => (context, next) => { foreach (var middleware in choices) { middleware(context, next); if (wasChosen(context)) { return; } } defaultAction(context, next); };
public static VoidSyncMiddleware <TContext> Compose <TContext>( this VoidSyncMiddleware <TContext> middleware, params VoidSyncMiddleware <TContext>[] middlewares) => middleware.Singleton().Concat(middlewares).Compose();
public static VoidSyncMiddlewareFunc <TContext> Combine <TContext>( this VoidSyncMiddleware <TContext> middleware, VoidSyncMiddlewareFunc <TContext> func) => context => middleware(context, func);