protected void ApplicationStartupForTests(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); pipelines.OnError.AddItemToEndOfPipeline( (ctx, ex) => new OnErrorHooks(_logger) .HandleInternalServerError( ctx, ex, container.Resolve <IResponseNegotiator>(), _env)); pipelines.AfterRequest += ctx => { foreach (var corsHeader in HttpResponseHeaders.CorsHeaders) { ctx.Response.Headers.Add(corsHeader.Item1, corsHeader.Item2); } }; //container registrations container.Register(_appConfig); container.Register(_logger); container.Register <NancyContextWrapper>(); container.RegisterServices(); container.RegisterInMemoryStores(); }
private void ConfigureRegistrations(TinyIoCContainer container) { container.Register(_appConfig); container.Register(_logger); var options = new MemoryCacheOptions(); var eventLogger = LogFactory.CreateEventLogger(_loggingLevelSwitch, _appConfig.ApplicationInsights); var serilogEventWriter = new SerilogEventWriter(eventLogger); container.Register <IEventWriter>(serilogEventWriter, "innerEventWriter"); container.Register(options); container.Register <ICouchDbSettings>(_appConfig.CouchDbSettings); container.Register <IPropertySettings>(_appConfig.DefaultPropertySettings); container.Register(typeof(IOptions <>), typeof(OptionsManager <>)); container.Register <IMemoryCache, MemoryCache>(); if (_appConfig.UseInMemoryStores) { container.RegisterInMemoryStores(); } else { container.Register <IDocumentDbService, CouchDbAccessService>("inner"); var dbAccessService = container.Resolve <CouchDbAccessService>(); dbAccessService.Initialize().Wait(); dbAccessService.AddViews("roles", CouchDbRoleStore.GetViews()).Wait(); dbAccessService.AddViews("permissions", CouchDbPermissionStore.GetViews()).Wait(); } }
private void RegisterStores(TinyIoCContainer container) { if (_appConfig.UseInMemoryStores) { container.RegisterInMemoryStores(); } else { container.RegisterCouchDbStores(_appConfig, _loggingLevelSwitch); } }