Ninject: Abstract Class
- by Pickels
Hello,
Do I need to do something different in an abstract class to get dependency injection working with Ninject?
I have a base controller with the following code:
public abstract class BaseController : Controller
{
public IAccountRepository AccountRepository
{
get;
set;
}
}
My module looks like this:
public class WebDependencyModule : NinjectModule
{
public override void Load()
{
Bind<IAccountRepository>().To<AccountRepository>();
}
}
And this is my Global.asax:
protected override void OnApplicationStarted()
{
Kernel.Load(new WebDependencyModule());
}
protected override IKernel CreateKernel()
{
return new StandardKernel();
}
It works when I decorate the IAccountRepository property with the [Inject] attribute.
Thanks in advance.