I'm using LightInject in an ASP MVC project. The initialization code is more or less the same as on: http://www.lightinject.net/#mvc
My question is how to resolve instances in static functions, for example an HTML helper:
public static string MyHtmlExtension(this HtmlHelper h)
{
var myService = new MyService(); // <- get this from container instead of creating new object
return myService.DoSomething(h);
}
Can I make the ServiceContainer
in the MvcApplication
class static or is that a bad practice?