// TODO: Remove this - but keeping it in for now until we prove in all cases that the ctor below is better. public ODataServerConfigurer(HttpConfiguration webApiConfig, IContainerMetadata containerMetadata) { Contract.Requires<ArgumentNullException>(webApiConfig != null); _webApiConfig = webApiConfig; _containerMetadata = containerMetadata; _controllerSelector = EntityRepositoryControllerSelector.Install(webApiConfig, this); }
/// <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; }
public ODataServerConfigurer(HttpConfiguration webApiConfig) { Contract.Requires<ArgumentNullException>(webApiConfig != null); _webApiConfig = webApiConfig; // Obtain the container metadata from the DI service _containerMetadata = webApiConfig.DependencyResolver.Resolve<IContainerMetadata>(); if (_containerMetadata == null) { throw new ArgumentException("IContainerMetadata could not be resolved from HttpConfiguration.DependencyResolver."); } _controllerSelector = EntityRepositoryControllerSelector.Install(webApiConfig, this); }