views:

91

answers:

2

Is it possible to know that particular dependency already has been satisfied by ninject kernel? To be clear:

Let's suppose we have this module:

Bind<IA>().To<A>();
Bind<IB>().To<B>();

And some "client"-code:

var a = kernel.Get<IA>();

// how to get here "true" for assumption: "IA was requested (once)"
// and "false" for: "IB was not requested ever"
+1  A: 

You could use .Before* and .After* in the fluent bindings to hook in a call to something to mark it used. Or you could look at the IDisposable hooks (see the tests in the source download).

There's good background info in http://kohari.org/2009/03/06/cache-and-collect-lifecycle-management-in-ninject-20/ too

Ruben Bartelink
Hmmmm, I haven't find any Before/After hooks in the sources. Can you point more specifically, please?
zerkms