/// <summary> /// Configure all the OWIN modules that participate in each request. /// </summary> /// <param name="app">The OWIN appBuilder</param> /// <remarks> /// The order of configuration is IMPORTANT - it sets the sequence of the request processing pipeline. /// </remarks> public void Configuration(IAppBuilder app) { #if DEBUG // Debug builds get full call stack in error pages. app.Properties["host.AppMode"] = "development"; #else app.Properties["host.AppMode"] = "release"; #endif // DependencyInjection config var diContainer = new Container { Options = { AllowOverridingRegistrations = true } }; diContainer.RegisterModules(new ODataServiceModule(), new AppModule()); // Configure logging ConfigureOwinLogging(app, diContainer); // Web API config var webApiConfig = new HttpConfiguration(); webApiConfig.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(diContainer); // Map routes using class attributes webApiConfig.MapHttpAttributeRoutes(); HttpServer webApiServer = new HttpServer(webApiConfig); WebApiConfig.ConfigureODataService(webApiConfig, webApiServer); app.UseWebApi(webApiServer); }
/// <summary> /// Returns a new <see cref="TestServer"/>, configured with WebApp.Web startup code. /// Requests against the test server are processed directly in memory without going over the network. /// </summary> /// <param name="iocModule">Configures the odata model for the test in SimpleInjector</param> /// <param name="odataConfigAction">Optional configuration for <see cref="ODataServerConfigurer"/>.</param> /// <returns></returns> /// <remarks> /// Note that the returned <see cref="TestServer"/> should be disposed. /// </para> /// </remarks> protected TestServer CreateTestServer(IModule iocModule, Action<ODataServerConfigurer> odataConfigAction = null) { // Setup the DI container Container container = new Container { Options = { AllowOverridingRegistrations = true } }; container.RegisterModules(new ODataServiceModule(), iocModule); var testServer = TestServer.Create(owinAppBuilder => ConfigureOwinPipeline(owinAppBuilder, container, odataConfigAction)); // Ensure logging setup is healthy _tracerFactory.TracerFor(this).Info("Test OData server started..."); Assert.True(_logManager.IsHealthy); return testServer; }
protected void Application_Start() { // ASP.NET MVC setup AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); // DI config var container = new Container { Options = { AllowOverridingRegistrations = true } }; container.RegisterModules(new ODataServiceModule(), new AppModule()); // Web API config GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); GlobalConfiguration.Configure(WebApiConfig.Register); //MvcRouteConfig.RegisterRoutes(RouteTable.Routes); }