コード例 #1
0
        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();
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 private void RegisterStores(TinyIoCContainer container)
 {
     if (_appConfig.UseInMemoryStores)
     {
         container.RegisterInMemoryStores();
     }
     else
     {
         container.RegisterCouchDbStores(_appConfig, _loggingLevelSwitch);
     }
 }