I'm building a message broker with NInject, and I need to find all instances in the container that implement Consumes, an interface that marks the class as being able to consume a particular message type.
Is this scenario supported?
Answer from Nate:
Multi-resolution (via
GetAll
) is currently not polymorphic. That means that it will only consider bindings from the exact interface you specify. If you do this:kernel.Bind<IWorker>().To<WorkerA>(); kernel.Bind<IWorker>().To<WorkerB>(); kernel.Bind<IWorker>().To<WorkerC>();
And then:
kernel.GetAll<IWorker>();
It will return 3 items. However, even if
IWorkerA
,IWorkerB
, andIWorkerC
implementIWorker
, Ninject will not look at bindings fromIWorkerA
toWorkerA
when you ask forIWorker
.
See :
http://groups.google.com/group/ninject/browse_thread/thread/7b6afa06099bc97a#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With