public void Configuration(IAppBuilder appBuilder) { var bootstrapper = new WindsorBootstrapper(AppDomain.CurrentDomain.BaseDirectory, filter: "Marketing*.*"); var container = bootstrapper.Boot(); var store = CommonConfiguration.CreateEmbeddableDocumentStore("Marketing", session => { SeedData.Products().ForEach(s => session.Store(s)); session.Store(SeedData.HomeStructure()); }); container.Register(Component.For <IDocumentStore>().Instance(store).LifestyleSingleton()); var endpointConfiguration = new EndpointConfiguration("Marketing"); endpointConfiguration.UseContainer <WindsorBuilder>(c => c.ExistingContainer(container)); endpointConfiguration.ApplyCommonConfiguration(); endpointConfiguration.UseRavenPersistence(store); endpointConfiguration.LimitMessageProcessingConcurrencyTo(1); //var timeoutManager = endpointConfiguration.TimeoutManager(); //timeoutManager.LimitMessageProcessingConcurrencyTo(4); var endpoint = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult(); container.Register(Component.For <IMessageSession>().Instance(endpoint)); var config = new HttpConfiguration(); config.Formatters.Clear(); config.Formatters.Add(new JsonMediaTypeFormatter()); config.DependencyResolver = new WindsorDependencyResolver(container); config.Formatters .JsonFormatter .SerializerSettings .ContractResolver = new CamelCasePropertyNamesContractResolver(); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); appBuilder.UseCors(CorsOptions.AllowAll); appBuilder.UseWebApi(config); }
// This code configures Web API. The Startup class is specified as a type // parameter in the WebApp.Start method. public void Configuration(IAppBuilder appBuilder) { var bootstrapper = new WindsorBootstrapper(AppDomain.CurrentDomain.BaseDirectory, filter: "CustomerCare*.*"); var container = bootstrapper.Boot(); var store = CommonConfiguration.CreateEmbeddableDocumentStore("CustomerCare", session => { SeedData.Raitings().ForEach(r => session.Store(r)); SeedData.Reviews().ForEach(r => session.Store(r)); }); container.Register(Component.For <IDocumentStore>().Instance(store).LifestyleSingleton()); var config = new HttpConfiguration(); config.Formatters.Clear(); config.Formatters.Add(new JsonMediaTypeFormatter()); config.DependencyResolver = new WindsorDependencyResolver(container); config.Formatters .JsonFormatter .SerializerSettings .ContractResolver = new CamelCasePropertyNamesContractResolver(); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); HttpServer server = new HttpServer(config); config.Routes.MapHttpBatchRoute( routeName: "batch", routeTemplate: "api/batch", batchHandler: new DefaultHttpBatchHandler(server) ); appBuilder.UseCors(CorsOptions.AllowAll); appBuilder.UseWebApi(config); }