I have an ASP.NET MVC 3 project using Ninject (NuGet install). I'm trying to understand how I can use it to inject dependencies into non-MVC objects.
I have some code that looks similar to below. How can I use Ninject to get a concrete instance of IStore in the object below?
public class SomeObject
{
private static IStore _store;
public static IStore CurrentStore
{
get
{
if (_store == null)
{
// Get Instance of _store.
}
return _store;
}
}
}
In Global.asax:
protected Application_BeginRequest()
{
IStore store = SomeObject.CurrentStore;
}
In NinjectWebCommon.cs:
private static void RegisterServices(IKernel kernel)
{
// Module that binds a concrete type of IStore.
kernel.Load<WebModule>();
}