Consider the following:
public Something(IInterface concreteObjectOne, IInterface concreteObjectTwo)
{
this.concreteObjectOne = concreteObjectOne;
this.concreteObjectTwo = concreteObjectTwo;
}
How do I set set this type of binding up with Ninject? I’d try Googling the term, but as I’m not sure what this is called I can’t, nor can I find anything on the Wiki about this.
Edit:
I believe this is called Convention Based Binding, as described here. However this documentation is for version 1.0 and 2.0 does not have the Only method. I’d like this to be achieved without attributes – using the convention of names or something similiar.
In addition to the use of “Only” method, the article suggests another solution by specifying different attributes for the injected objects.
Example:
Then
And when you want to bind the interface to the correct concrete object, use the “WhereTargetHas” method:
Update: Solution without using attributes:
Use the method “When”:
;