|
|
@@ -1,5 +1,6 @@
|
|
|
using CronAlarm.Config;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
|
using Ninject;
|
|
|
using Ninject.Web.AspNetCore;
|
|
|
using Ninject.Web.AspNetCore.Hosting;
|
|
|
@@ -32,7 +33,23 @@ namespace CronAlarm
|
|
|
|
|
|
kernel.Load(typeof(AspNetCoreHostConfiguration).Assembly);
|
|
|
|
|
|
- kernel.Bind<AlertConfig>().ToSelf();
|
|
|
+ kernel.Bind<ICrontFragmentHandler>().To<CronFragmentHandler>();
|
|
|
+
|
|
|
+ kernel.Bind<Alerts>().ToMethod(ctx =>
|
|
|
+ {
|
|
|
+ var config = ctx.Kernel.Get<IConfiguration>();
|
|
|
+ var section = new Alerts();
|
|
|
+ config.GetSection("Alerts").Bind(section);
|
|
|
+ return section;
|
|
|
+ });
|
|
|
+
|
|
|
+ kernel.Bind<CronFragment>().ToMethod(ctx =>
|
|
|
+ {
|
|
|
+ var config = ctx.Kernel.Get<IConfiguration>();
|
|
|
+ var section = new CronFragment();
|
|
|
+ config.GetSection("CronFragment").Bind(section);
|
|
|
+ return section;
|
|
|
+ });
|
|
|
|
|
|
return kernel;
|
|
|
}
|