Last active
August 29, 2015 14:19
-
-
Save eshapovalova/b742bc4faa61579c6cc7 to your computer and use it in GitHub Desktop.
Web API Activator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UnityApiControllerActivator : IHttpControllerActivator | |
| { | |
| private readonly IUnityContainer _container; | |
| public UnityApiControllerActivator(IUnityContainer container) | |
| { | |
| _container = container; | |
| } | |
| public IHttpController Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) | |
| { | |
| return (IHttpController) _container.Resolve(controllerType); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var container = new UnityContainer(); | |
| GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container); | |
| container.RegisterInstance<IHttpControllerActivator>(new UnityApiControllerActivator(container)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment