Ejemplo n.º 1
0
        private static void Configuration(IAppBuilder appBuilder, Type targetController)
        {
            var config = appBuilder.GetStandardHttpConfig(targetController);

            var controllerSelector = new UnitTestODataVersionControllerSelector(config, targetController);

            config.Services.Replace(typeof(IHttpControllerSelector), controllerSelector);

            // Define a route to a controller class that contains functions
            config.MapODataServiceRoute("FunctionsODataRoute", "odata/v1", GetFunctionsEdmModel());
            controllerSelector.RouteVersionSuffixMapping.Add("FunctionsODataRoute", "V1");

            config.EnsureInitialized();
        }
Ejemplo n.º 2
0
        private static void Configuration(IAppBuilder appBuilder, Type targetController, Action <HttpConfiguration> configAction)
        {
            var config = appBuilder.GetStandardHttpConfig(targetController);

            var controllerSelector = new UnitTestODataVersionControllerSelector(config, targetController);

            config.Services.Replace(typeof(IHttpControllerSelector), controllerSelector);

            configAction(config);

            controllerSelector.RouteVersionSuffixMapping.Add("FunctionsODataRoute", "V1");

            config.EnsureInitialized();
        }
Ejemplo n.º 3
0
        private static void Configuration(IAppBuilder appBuilder, Type targetController = null, Action <SwaggerDocsConfig> swaggerDocsConfig = null, Action <ODataSwaggerDocsConfig> odataSwaggerDocsConfig = null)
        {
            var config = appBuilder.GetStandardHttpConfig(swaggerDocsConfig, odataSwaggerDocsConfig, targetController);

            var controllerSelector = new UnitTestODataVersionControllerSelector(config, targetController);

            config.Services.Replace(typeof(IHttpControllerSelector), controllerSelector);

            WebApiConfig.Register(config);

            // Define a versioned route
            config.MapODataServiceRoute("V1RouteVersioning", "odata/v1", GetVersionedModel());
            controllerSelector.RouteVersionSuffixMapping.Add("V1RouteVersioning", "V1");

            // Define a versioned route that doesn't map to any controller
            config.MapODataServiceRoute("odata/v2", "odata/v2", GetFakeModel());
            controllerSelector.RouteVersionSuffixMapping.Add("odata/v2", "V2");

            // Define a default non- versioned route(default route should be at the end as a last catch-all)
            config.MapODataServiceRoute("DefaultODataRoute", "odata", GetDefaultModel());

            config.EnsureInitialized();
        }