I'm on a ASP NET MVC 5 web application inside a multi-tier solution.
The general scenario is the following: the controller Mvc uses a proxy to call methods from the services (Rest and Service2), the services call the methods from the business logic layer.
I have to use Unity as a dependency injection container to solve the dependencies in the controller, I'm not sure whether or not I understood it correctly.
What I assumed is the following: as the dependencies in the controller are the Service2Proxy and the RestServiceProxy, I registered these proxies as the components in the UnityConfig file.
As regards the implementation of the DI, I added property of type IProxy to the controller and I assigned the value of a specific proxy to it inside the constructor.
I wonder whether or not it is correct because I don't see the need of configuring Unity to do that, therefore I maybe have to look at it in a different way...?
What I have tried:
in the UnityConfig:
public static void RegisterComponents()
{
var container = new UnityContainer();
container.RegisterType<IProxy, RESTProxy>();
container.RegisterType<IProxy, Service2Proxy>();
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
}
In the controller:
private IProxy _proxy;
public MovieMvcController(RESTProxy proxy)
{
this._proxy= proxy;
}
And then I use _proxy to call the methods inside the actions