Esempio n. 1
0
        protected override void UpdateConfiguration(WebRouteConfiguration configuration)
        {
            var controllers = new[] { typeof(BaseAddressFactoryModelsController) };

            configuration.AddControllers(controllers);
            var model = GetEdmModel(configuration);

            configuration.Routes.Clear();
            configuration.MapODataServiceRoute("odata", "odata", model);
            configuration.EnsureInitialized();

            ServicesContainer       services           = configuration.Services;
            IHttpControllerSelector controllerSelector = services.GetHttpControllerSelector();
            var controllerMappings = controllerSelector.GetControllerMapping().Values;

            foreach (var c in controllerMappings)
            {
                var odataFormatter = c.Configuration.Formatters.OfType <ODataMediaTypeFormatter>();
                foreach (var f in odataFormatter)
                {
                    f.BaseAddressFactory = (m) => new Uri("http://foo.bar/", UriKind.Absolute);
                }
            }
        }
 private EntityRepositoryControllerSelector(ServicesContainer servicesContainer, ODataServerConfigurer oDataServerConfigurer)
 {
     _fallbackControllerSelector = servicesContainer.GetHttpControllerSelector();
     _managedControllers = new Dictionary<string, HttpControllerDescriptor>(ODataServerConfigurer.InitialEntitySetCapacity, StringComparer.OrdinalIgnoreCase);
 }