I have a class that should use IRepository for one method in it class.
Ideally, I would like to avoid the need to allow this dependency in the class constructor, and so I found a method level injection in Ninject and wondered how it works?
I understand how to configure it. What am I embarrassed is to call it?
Example:
class SomeClassThatUsesRepository
{
[Inject]
public void QueryForSomeStuff(IRepository repository)
{
}
}
My problem is, how can I call this method without specifying an IRepository?
var someClass = Kernel.Resolve<SomeClassThatUsesRepository>();
will work if I use the constructor, but I want to call the method.
How do I call a method using the Ninject method?
source
share