コード例 #1
0
ファイル: AppBuilderExtensions.cs プロジェクト: zsu/Quartzmin
        public static void UseQuartzmin(this IAppBuilder app, QuartzminOptions options, Action <Services> configure = null)
        {
            options = options ?? throw new ArgumentNullException(nameof(options));

            app.UseFileServer(options);

            var services = Services.Create(options);

            configure?.Invoke(services);

            app.Use((owin, next) =>
            {
                owin.Set(Services.ContextKey, services);
                return(next());
            });

            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: nameof(Quartzmin),
                routeTemplate: "{controller}/{action}",
                defaults: new { controller = "Scheduler", action = "Index" }
                );

            config.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter(new MultipartFormatterSettings()
            {
                ValidateNonNullableMissedProperty = false, CultureInfo = CultureInfo.InvariantCulture
            }));

            config.Services.Replace(typeof(IHostBufferPolicySelector), new BufferPolicySelector());
            config.Services.Replace(typeof(IExceptionHandler), new ExceptionHandler((IExceptionHandler)config.Services.GetService(typeof(IExceptionHandler)), services.ViewEngine.ErrorPage, true));

            app.UseWebApi(config);
        }
コード例 #2
0
        public static void UseQuartzmin(this IApplicationBuilder app, QuartzminOptions options, Action <Services> configure = null)
        {
            options = options ?? throw new ArgumentNullException(nameof(options));

            app.UseFileServer(options);

            var services = Services.Create(options);

            configure?.Invoke(services);

            app.Use(async(context, next) =>
            {
                context.Items[typeof(Services)] = services;
                await next.Invoke();
            });


#if NETCOREAPP
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(nameof(Quartzmin), $"{options.VirtualPathRoot}/{{controller=Scheduler}}/{{action=Index}}");
            });
#else
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: nameof(Quartzmin),
                    template: "{controller=Scheduler}/{action=Index}");
            });
#endif
        }
コード例 #3
0
        public static void UseQuartzmin(this IApplicationBuilder app, QuartzminOptions options, Action <Services> configure = null)
        {
            options = options ?? throw new ArgumentNullException(nameof(options));

            app.UseFileServer(options);

            var services = Services.Create(options);

            configure?.Invoke(services);

            app.Use(async(context, next) =>
            {
                context.Items[typeof(Services)] = services;
                await next.Invoke();
            });

            app.UseExceptionHandler(errorApp =>
            {
                errorApp.Run(async context =>
                {
                    var ex = context.Features.Get <IExceptionHandlerFeature>().Error;
                    context.Response.StatusCode  = 500;
                    context.Response.ContentType = "text/html";
                    await context.Response.WriteAsync(services.ViewEngine.ErrorPage(ex));
                });
            });
        }
コード例 #4
0
        public static void UseQuartzmin(this IApplicationBuilder app, QuartzminOptions options, Action <Services> configure = null)
        {
            options = options ?? throw new ArgumentNullException(nameof(options));

            app.UseFileServer(options);

            var services = Services.Create(options);

            configure?.Invoke(services);

            app.Use(async(context, next) =>
            {
                context.Items[typeof(Services)] = services;
                await next.Invoke();
            });
        }
コード例 #5
0
        public static void UseQuartzmin(this IApplicationBuilder app, QuartzminOptions options, Action <Services> configure = null)
        {
            options = options ?? throw new ArgumentNullException(nameof(options));

            app.UseFileServer(options);

            var services = Services.Create(options);

            configure?.Invoke(services);

            app.Use(async(context, next) =>
            {
                context.Items[typeof(Services)] = services;
                await next.Invoke();
            });

            app.UseExceptionHandler(errorApp =>
            {
                errorApp.Run(async context =>
                {
                    var ex = context.Features.Get <IExceptionHandlerFeature>().Error;
                    context.Response.StatusCode  = 500;
                    context.Response.ContentType = "text/html";
                    await context.Response.WriteAsync(services.ViewEngine.ErrorPage(ex));
                });
            });

#if NETCORE
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(nameof(Quartzmin), "{controller=Scheduler}/{action=Index}");
            });
#endif

#if NETSTANDARD
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: nameof(Quartzmin),
                    template: "{controller=Scheduler}/{action=Index}");
            });
#endif
        }