protected virtual Middleware.Middleware Build(IList <Middleware.Middleware> middlewares) { Middleware.Middleware next = new NoOpMiddleware(); for (var i = middlewares.Count - 1; i >= 0; i--) { Middleware.Middleware cancellation = new CancellationMiddleware(); var current = middlewares[i]; current.Next = cancellation; cancellation.Next = next; next = current; } return(next); }
/// <summary> /// Sets <see cref="AppConfig.CancellationToken"/> and cancels the token on /// <see cref="Console.CancelKeyPress"/>, <see cref="AppDomain.ProcessExit"/> and /// <see cref="AppDomain.UnhandledException"/> if <see cref="UnhandledExceptionEventArgs.IsTerminating"/> is true.<br/> /// Once cancelled, the pipelines will not progress to the next step. /// </summary> public static AppRunner UseCancellationHandlers(this AppRunner appRunner) { return(CancellationMiddleware.UseCancellationHandlers(appRunner)); }