/// <summary> /// Configures the OWIN pipeline for a test. /// </summary> /// <param name="owinAppBuilder"></param> /// <param name="iocContainer">A SimpleInjector IOC container.</param> /// <param name="odataConfigAction">Optional configuration for <see cref="ODataServerConfigurer"/>.</param> protected virtual void ConfigureOwinPipeline(IAppBuilder owinAppBuilder, Container iocContainer, Action <ODataServerConfigurer> odataConfigAction = null) { // Test class name is the app name owinAppBuilder.Properties["host.AppName"] = GetType().FullName; owinAppBuilder.Properties["EntityRepository.InUnitTest"] = true; // In case any test-conditional logic is needed // HTTP and trace logging ConfigureLogging(owinAppBuilder, out _logManager, out _tracerFactory); // Request filter method, useful breakpoint for debugging owinAppBuilder.Use(TestRequestFilter); // Add Web API to the Owin pipeline HttpConfiguration webApiConfig = new HttpConfiguration(); //webApiConfig.EnableSystemDiagnosticsTracing(); // Use SimpleInjector as the web API DependencyResolver webApiConfig.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(iocContainer); HttpServer webApiServer = new HttpServer(webApiConfig); // Configure EntityRepository.ODataServer controllers var oDataServerConfigurer = new ODataServerConfigurer(webApiConfig); if (odataConfigAction != null) { odataConfigAction(oDataServerConfigurer); } oDataServerConfigurer.AddStandardEntitySetControllers(); oDataServerConfigurer.ConfigureODataRoutes(webApiServer.Configuration.Routes, "ODataRoute", "odata", webApiServer); owinAppBuilder.UseWebApi(webApiServer); // Verify that DI config is valid; and initialize everything iocContainer.Verify(); }
internal static void ConfigureODataService(HttpServer server) { // Configure OData controllers var oDataServerConfigurer = new ODataServerConfigurer(server.Configuration); oDataServerConfigurer.AddStandardEntitySetControllers(); oDataServerConfigurer.ConfigureODataRoutes(server.Configuration.Routes, "ODataRoute", "odata", server); }
/// <summary> /// Installs an <see cref="EntityRepositoryControllerSelector"/> as the top level <see cref="IHttpControllerSelector"/> in <paramref name="webApiConfig"/>. /// </summary> /// <param name="webApiConfig"></param> /// <param name="oDataServerConfigurer"></param> /// <returns></returns> public static EntityRepositoryControllerSelector Install(HttpConfiguration webApiConfig, ODataServerConfigurer oDataServerConfigurer) { Contract.Requires<ArgumentNullException>(webApiConfig != null); Contract.Requires<ArgumentNullException>(oDataServerConfigurer != null); var instance = new EntityRepositoryControllerSelector(webApiConfig.Services, oDataServerConfigurer); if (instance._fallbackControllerSelector is EntityRepositoryControllerSelector) { // Skip duplicate installation return instance._fallbackControllerSelector as EntityRepositoryControllerSelector; } webApiConfig.Services.Replace(typeof(IHttpControllerSelector), instance); return instance; }
internal static void ConfigureODataService(HttpConfiguration webApiConfig, HttpServer webApiServer) { // Configure OData controllers var oDataServerConfigurer = new ODataServerConfigurer(webApiConfig); // Just to prove that regular controller classes can be added when customization is needed // However, this isn't needed, b/c the dependency injector normally picks up all controllers in the assembly. //oDataServerConfigurer.AddEntitySetController("Projects", typeof(Project), typeof(ProjectsController)); //oDataServerConfigurer.AddEntitySetController("Users", typeof(User), typeof(UsersController)); oDataServerConfigurer.AddStandardEntitySetControllers(DbSetControllerSelector); // TODO: Remove this - using to compare ODataConventionModelBuilder's EDM to what EF creates. var odataModelBuilder = new ODataConventionModelBuilder(webApiConfig); odataModelBuilder.ConfigureFromContainer(oDataServerConfigurer.ContainerMetadata); oDataServerConfigurer.ConfigureODataRoutes(webApiConfig.Routes, "ODataRoute", ODataRoute, webApiServer, // TODO: Remove this arg odataModelBuilder.GetEdmModel()); }
private EntityRepositoryControllerSelector(ServicesContainer servicesContainer, ODataServerConfigurer oDataServerConfigurer) { _fallbackControllerSelector = servicesContainer.GetHttpControllerSelector(); _managedControllers = new Dictionary<string, HttpControllerDescriptor>(ODataServerConfigurer.InitialEntitySetCapacity, StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Configures the OWIN pipeline for a test. /// </summary> /// <param name="owinAppBuilder"></param> /// <param name="iocContainer">A SimpleInjector IOC container.</param> /// <param name="odataConfigAction">Optional configuration for <see cref="ODataServerConfigurer"/>.</param> protected virtual void ConfigureOwinPipeline(IAppBuilder owinAppBuilder, Container iocContainer, Action<ODataServerConfigurer> odataConfigAction = null) { // Test class name is the app name owinAppBuilder.Properties["host.AppName"] = GetType().FullName; owinAppBuilder.Properties["EntityRepository.InUnitTest"] = true; // In case any test-conditional logic is needed // HTTP and trace logging ConfigureLogging(owinAppBuilder, out _logManager, out _tracerFactory); // Request filter method, useful breakpoint for debugging owinAppBuilder.Use(TestRequestFilter); // Add Web API to the Owin pipeline HttpConfiguration webApiConfig = new HttpConfiguration(); //webApiConfig.EnableSystemDiagnosticsTracing(); // Use SimpleInjector as the web API DependencyResolver webApiConfig.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(iocContainer); HttpServer webApiServer = new HttpServer(webApiConfig); // Configure EntityRepository.ODataServer controllers var oDataServerConfigurer = new ODataServerConfigurer(webApiConfig); if (odataConfigAction != null) { odataConfigAction(oDataServerConfigurer); } oDataServerConfigurer.AddStandardEntitySetControllers(); oDataServerConfigurer.ConfigureODataRoutes(webApiServer.Configuration.Routes, "ODataRoute", "odata", webApiServer); owinAppBuilder.UseWebApi(webApiServer); // Verify that DI config is valid; and initialize everything iocContainer.Verify(); }
/// <summary> /// Installs an <see cref="EntityRepositoryControllerSelector"/> as the top level <see cref="IHttpControllerSelector"/> in <paramref name="webApiConfig"/>. /// </summary> /// <param name="webApiConfig"></param> /// <param name="oDataServerConfigurer"></param> /// <returns></returns> public static EntityRepositoryControllerSelector Install(HttpConfiguration webApiConfig, ODataServerConfigurer oDataServerConfigurer) { Contract.Requires<ArgumentNullException>(webApiConfig != null); Contract.Requires<ArgumentNullException>(oDataServerConfigurer != null); var instance = new EntityRepositoryControllerSelector(webApiConfig.Services, oDataServerConfigurer); if (instance._fallbackControllerSelector is EntityRepositoryControllerSelector) { // Skip duplicate installation return instance._fallbackControllerSelector as EntityRepositoryControllerSelector; } webApiConfig.Services.Replace(typeof(IHttpControllerSelector), instance); return instance; }
private EntityRepositoryControllerSelector(ServicesContainer servicesContainer, ODataServerConfigurer oDataServerConfigurer) { _fallbackControllerSelector = servicesContainer.GetHttpControllerSelector(); _managedControllers = new Dictionary<string, HttpControllerDescriptor>(ODataServerConfigurer.InitialEntitySetCapacity, StringComparer.OrdinalIgnoreCase); }