protected override void Load(ContainerBuilder builder) { var databaseDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Jarvis"); var store = new EmbeddableDocumentStore { DataDirectory = databaseDir, UseEmbeddedHttpServer = true }.Initialize(); builder.RegisterInstance(store).As<IDocumentStore>(); builder.Register(c => c.Resolve<IDocumentStore>().OpenSession()).As<IDocumentSession>().OnRelease(d => d.Dispose()); builder.RegisterType<SimpleScheduler>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo<IJarvisModule>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo<ISubOptionsProvider>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo<IScheduledJob>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo<IJarvisOptionsProvider>().As<IJarvisOptionsProvider>().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AsSelf(); builder.Register( c => { var session = c.Resolve<IDocumentSession>(); var config = session.Load<GmailModuleConfig>("GmailModuleConfig"); if(config == null) { config = new GmailModuleConfig(); session.Store(config); session.SaveChanges(); } return config; }); }
protected override void Load(ContainerBuilder builder) { var databaseDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Jarvis"); var store = new EmbeddableDocumentStore { DataDirectory = databaseDir, UseEmbeddedHttpServer = true }.Initialize(); builder.RegisterInstance(store).As <IDocumentStore>(); builder.Register(c => c.Resolve <IDocumentStore>().OpenSession()).As <IDocumentSession>().OnRelease(d => d.Dispose()); builder.RegisterType <SimpleScheduler>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo <IJarvisModule>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo <ISubOptionsProvider>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo <IScheduledJob>().AsImplementedInterfaces().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AssignableTo <IJarvisOptionsProvider>().As <IJarvisOptionsProvider>().SingleInstance(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly()).AsSelf(); builder.Register( c => { var session = c.Resolve <IDocumentSession>(); var config = session.Load <GmailModuleConfig>("GmailModuleConfig"); if (config == null) { config = new GmailModuleConfig(); session.Store(config); session.SaveChanges(); } return(config); }); }
public GmailModule(GmailModuleConfig config) { _config = config; }