I am currently inserting a dependency in my mvc controller as shown below:
public class HomeController : Controller
{
[Dependency]
public IProxyService ProxyService { get; set; }
}
In global.asax, the type is registered using
UnityContainer _container = new UnityContainer();
_container.RegisterType<IProxyService, SystemProxyServiceEx>();
Now, I need to pass a few parameters to the SystemProxyServiceEx constructor. These include some values stored in the session variable(HttpSessionStateBase Session) that are stored during authentication. How do I make this happen?
The common thing to do is to wrap those in a class and inject it based on an interface. For instance:
Now you can make your
SystemProxyServiceExtake a dependency onIUserContext. Last step is to register it, which of course will be easy: