Unity Interception : Can it be used to know what types are being registered in container

Dec 18, 2008 at 3:50 PM
I haven't explore interception yet.

But can it be used to know what types are being added to Contaibner.

For e.g. ServiceA depends on ServiceB and ServiceC.

ServiceA takes only IContainer as constructor param.

In constructor ServiceA will try to resolve ServiceB and ServiceC.

Lets say ServiceB is available but ServiceC is not available yet.

ServiceA would like to add interceptor to know when ServiceC is added to Container.

when ServiceA has intercepted addition of ServiceC it will consume it and use going forward .

Dec 22, 2008 at 7:22 AM
I think you should be subscribing to events rather than configuring interceptors.  You can create your own container and define delegates to subscribe to the Register methods.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
Dec 22, 2008 at 1:19 PM
Thanks Sarah. Yes i can do that I am already using my own drived container. I was just curious if we can do by interceptors.
Dec 22, 2008 at 6:21 PM
You don't need to derive a new container class, just build a container extension that hooks up to the Registered events.
Dec 24, 2008 at 2:33 PM
I am wrapping unity container into my class with some added functionality.

Now I get it. I created custom extension and in PostBuildUp I can figure out what was added to Unity and the fire events