예제 #1
0
        /// <summary>
        /// Adds <see cref="ReloadPipelineMiddleware"/> to the middleware pipeline, with a change token to invalidate it and rebuild it.
        /// </summary>
        /// <param name="builder"></param>
        ///<param name="registerListener">Function that registers a callback to be invoked when a change occurs, and returns an <see cref="IDisposable"/> that will remove the registration when the caller disposes of it in order to stop being notifified.</param>
        /// <param name="configure"></param>
        /// <param name="isTerminal"></param>
        /// <returns></returns>
        public static IApplicationBuilder AddReloadablePipelineMiddleware(this IApplicationBuilder builder,
                                                                          Func <Action, IDisposable> registerListener,
                                                                          Action <IApplicationBuilder> configure,
                                                                          bool isTerminal)
        {
            var changeTokenFactory = ChangeTokenFactoryHelper.UseCallbackRegistrations(registerListener);

            return(ChangeTokenExtensions.AddReloadablePipelineMiddleware(builder, changeTokenFactory, configure, isTerminal));
        }
예제 #2
0
        /// <summary>
        /// Adds <see cref="ReloadPipelineMiddleware"/> to the middleware pipeline, with a factory method that can supply a <see cref="CancellationToken"/> that can be used to invalidate it and cause a reload.
        /// </summary>
        /// <param name="builder"></param>
        ///<param name="getCancellationToken">Function that returns a cancellation token that will be signalled when the pipeline needs to be reloaded.</param>
        /// <param name="configure"></param>
        /// <param name="isTerminal"></param>
        /// <returns></returns>
        public static IApplicationBuilder AddReloadablePipelineMiddleware(this IApplicationBuilder builder,
                                                                          Func <CancellationToken> getCancellationToken,
                                                                          Action <IApplicationBuilder> configure,
                                                                          bool isTerminal)
        {
            var changeTokenFactory = ChangeTokenFactoryHelper.UseCancellationTokens(getCancellationToken);

            return(ChangeTokenExtensions.AddReloadablePipelineMiddleware(builder, changeTokenFactory, configure, isTerminal));
        }