I have a class (MyFacade
) that I injected parameter(s) with Ninject
:
class MyFacade
{
IDemoInterface demo;
public MyFacade(IDe
When setting up your bindings, you need to bind your dependencies. It is always better to setup your dependencies in your bindings, as opposed to doing a kernel.Get
in a constructor. You are using IOC, so leverage the framework you are using to do the injection for you.
In your second example binding, what you are missing is binding in your IDemoInterface
. Your bindings should look like this:
//bind the dependency to the implementation.
kernel.Bind().To();
//since you bound your dependency, ninject should now have
// all the dependencies required to instantiate your `MyFacade` object.
kernel.Bind().To().InSingletonScope();