I successfully use Ninject in a project where I can have a class like this:
public class MyServiceConsumer
{
[Inject]
public void IPropertyInjectedService { get; set; }
private IConstructorInjectedService _conSvc;
public MyServiceConsumer(IConstructorInjectedService conSvc)
{
_conSvc = conSvc;
}
}
And if I do kernel.Get <MyServiceConsumer> (), the dependencies will be satisfied, and everything will be fine. But there is one scenario with running the application, in which I already have an existing object, and I would like to pass it to the kernel so that the kernel injects properties in this existing instance.
How to pass an existing object to the Ninject core to execute dependency injection dependencies?
source
share