|
|
@@ -1,10 +1,11 @@
|
|
|
using CronAlarm.Config;
|
|
|
+using Microsoft.AspNetCore.Builder;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
+using Microsoft.Extensions.DependencyInjection;
|
|
|
+using Microsoft.Extensions.Hosting;
|
|
|
using Ninject;
|
|
|
using Ninject.Web.AspNetCore;
|
|
|
-using Ninject.Web.AspNetCore.Hosting;
|
|
|
-using Ninject.Web.Common.SelfHost;
|
|
|
|
|
|
namespace CronAlarm
|
|
|
{
|
|
|
@@ -12,28 +13,38 @@ namespace CronAlarm
|
|
|
{
|
|
|
public static void Main(string[] args)
|
|
|
{
|
|
|
- var hostConfiguration = new AspNetCoreHostConfiguration(args)
|
|
|
- .UseWebHostBuilder(() => CreateWebHostBuilder(args))
|
|
|
- .UseStartup<Startup>()
|
|
|
- .UseKestrel()
|
|
|
- .BlockOnStart();
|
|
|
+ var kernel = CreateKernel();
|
|
|
+ var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
- var host = new NinjectSelfHostBootstrapper(CreateKernel, hostConfiguration);
|
|
|
- host.Start();
|
|
|
- }
|
|
|
+ builder.Host.UseServiceProviderFactory(new NinjectServiceProviderFactory(kernel));
|
|
|
|
|
|
- private static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
|
|
- {
|
|
|
- var config = new DefaultWebHostConfiguration(args);
|
|
|
+ // Add services to the container.
|
|
|
+ builder.Services.AddRazorPages();
|
|
|
+ builder.Services.AddServerSideBlazor();
|
|
|
+ builder.Host.ConfigureAppConfiguration((hostingContext, config) =>
|
|
|
+ {
|
|
|
+ config.AddJsonFile("wwwroot/data/settings.json", optional: true, reloadOnChange: true);
|
|
|
+ });
|
|
|
+
|
|
|
+ var app = builder.Build();
|
|
|
|
|
|
- config.ConfigureAll();
|
|
|
- return config.GetBuilder().ConfigureAppConfiguration((hostingContext, config) =>
|
|
|
- {
|
|
|
- config.AddJsonFile("wwwroot/data/settings.json", optional: true, reloadOnChange: true);
|
|
|
- });
|
|
|
+ // Configure the HTTP request pipeline.
|
|
|
+ if (!app.Environment.IsDevelopment())
|
|
|
+ {
|
|
|
+ app.UseExceptionHandler("/Error");
|
|
|
+ }
|
|
|
+
|
|
|
+ app.UseStaticFiles();
|
|
|
+
|
|
|
+ app.UseRouting();
|
|
|
+
|
|
|
+ app.MapBlazorHub();
|
|
|
+ app.MapFallbackToPage("/_Host");
|
|
|
+
|
|
|
+ app.Run();
|
|
|
}
|
|
|
|
|
|
- private static IKernel CreateKernel()
|
|
|
+ private static AspNetCoreKernel CreateKernel()
|
|
|
{
|
|
|
var settings = new NinjectSettings();
|
|
|
// Unfortunately, in .NET Core projects, referenced NuGet assemblies are not copied to the output directory
|
|
|
@@ -42,8 +53,8 @@ namespace CronAlarm
|
|
|
settings.LoadExtensions = false;
|
|
|
|
|
|
var kernel = new AspNetCoreKernel(settings);
|
|
|
-
|
|
|
- kernel.Load(typeof(AspNetCoreHostConfiguration).Assembly);
|
|
|
+ kernel.DisableAutomaticSelfBinding();
|
|
|
+ kernel.Load(new AspNetCoreModule());
|
|
|
|
|
|
kernel.Bind<CronApiClient>().ToSelf();
|
|
|
kernel.Bind<ICronSectionHandler>().To<CronSectionHandler>();
|