Exemplo n.º 1
0
        // 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);
        };
Exemplo n.º 2
0
 public static VoidSyncMiddleware <TContext> Compose <TContext>(
     this VoidSyncMiddleware <TContext> middleware,
     params VoidSyncMiddleware <TContext>[] middlewares) =>
 middleware.Singleton().Concat(middlewares).Compose();
Exemplo n.º 3
0
 public static VoidSyncMiddlewareFunc <TContext> Combine <TContext>(
     this VoidSyncMiddleware <TContext> middleware,
     VoidSyncMiddlewareFunc <TContext> func) =>
 context => middleware(context, func);