Esempio n. 1
0
        /// <summary>
        /// Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in <paramref name="optionsAction"/>.
        /// </summary>
        /// <param name="app">The <see cref="IApplicationBuilder"/> to register the middleware with.</param>
        /// <param name="optionsAction">An action to set the options for the middleware.</param>
        /// <returns>The same <see cref="IApplicationBuilder"/> instance so that multiple calls can be chained.</returns>
        public static IApplicationBuilder UseMigrationsEndPoint([NotNull] this IApplicationBuilder app, [NotNull] Action <MigrationsEndPointOptions> optionsAction)
        {
            Check.NotNull(app, "builder");
            Check.NotNull(optionsAction, "optionsAction");

            var options = new MigrationsEndPointOptions();

            optionsAction(options);

            return(app.UseMiddleware <MigrationsEndPointMiddleware>(options));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MigrationsEndPointMiddleware"/> class
        /// </summary>
        /// <param name="next">Delegate to execute the next piece of middleware in the request pipeline.</param>
        /// <param name="serviceProvider">The <see cref="IServiceProvider"/> to resolve services from.</param>
        /// <param name="logger">The <see cref="Logger{T}"/> to write messages to.</param>
        /// <param name="options">The options to control the behavior of the middleware.</param>
        public MigrationsEndPointMiddleware(
            [NotNull] RequestDelegate next,
            [NotNull] IServiceProvider serviceProvider,
            [NotNull] ILogger <MigrationsEndPointMiddleware> logger,
            [NotNull] IOptions <MigrationsEndPointOptions> options)
        {
            Check.NotNull(next, "next");
            Check.NotNull(serviceProvider, "serviceProvider");
            Check.NotNull(logger, "logger");
            Check.NotNull(options, "options");

            _next            = next;
            _serviceProvider = serviceProvider;
            _logger          = logger;
            _options         = options.Value;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MigrationsEndPointMiddleware"/> class
        /// </summary>
        /// <param name="next">Delegate to execute the next piece of middleware in the request pipeline.</param>
        /// <param name="logger">The <see cref="Logger{T}"/> to write messages to.</param>
        /// <param name="options">The options to control the behavior of the middleware.</param>
        public MigrationsEndPointMiddleware(
            RequestDelegate next,
            ILogger <MigrationsEndPointMiddleware> logger,
            IOptions <MigrationsEndPointOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next    = next;
            _logger  = logger;
            _options = options.Value;
        }
Esempio n. 4
0
        public static IApplicationBuilder UseMigrationsEndPoint([NotNull] this IApplicationBuilder builder, [NotNull] MigrationsEndPointOptions options)
        {
            Check.NotNull(builder, "builder");
            Check.NotNull(options, "options");

            return(builder.UseMiddleware <MigrationsEndPointMiddleware>(options));
        }
        public static IBuilder UseMigrationsEndPoint([NotNull] this IBuilder builder, [NotNull] MigrationsEndPointOptions options)
        {
            Check.NotNull(builder, "builder");
            Check.NotNull(options, "options");

            /* TODO: Development, Staging, or Production
             * string appMode = new AppProperties(builder.Properties).Get<string>(Constants.HostAppMode);
             * bool isDevMode = string.Equals(Constants.DevMode, appMode, StringComparison.Ordinal);*/
            bool isDevMode = true;

            return(builder.Use(next => new MigrationsEndPointMiddleware(next, options, isDevMode).Invoke));
        }
    /// <summary>
    /// Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in <paramref name="options"/>.
    /// </summary>
    /// <param name="app">The <see cref="IApplicationBuilder"/> to register the middleware with.</param>
    /// <param name="options">An action to set the options for the middleware.</param>
    /// <returns>The same <see cref="IApplicationBuilder"/> instance so that multiple calls can be chained.</returns>
    public static IApplicationBuilder UseMigrationsEndPoint(this IApplicationBuilder app, MigrationsEndPointOptions options)
    {
        if (app == null)
        {
            throw new ArgumentNullException(nameof(app));
        }
        if (options == null)
        {
            throw new ArgumentNullException(nameof(options));
        }

        return(app.UseMiddleware <MigrationsEndPointMiddleware>(Options.Create(options)));
    }