AOP interception of child methods using the Policy Injection block (EntLib 5.0)

Aug 17, 2010 at 5:20 PM

Trying to wrap my head around the use of PIAB / Unity, initially for logging

I've been through most of the Hands On Lab examples for PIAB and Unity and can see them working OK

Then tried with my own example and initially things were going alright

But I can't seem to get the interception to work for "child" calls,

e.g. the class has three methods ...  DoSomething(), DoFirst() and DoSecond()

DoSomething() calls DoFirst() and then DoSecond()

I can get interception of DoSomething, but I can't get anything for DoFirst and DoSecond

Tried various of the Policy Injection rules ... Type Matching, Tag Attribute, Method Signature ... but nothing works   :-(

But I can intercept if I call the methods directly

 

So basic question ... can you even do this ?

And if so, how !!

Aug 18, 2010 at 3:46 AM

The issue is how interception is implemented - by creating a proxy object. So the calls have to go through the proxy. Normally, self calls don't (and can't) do this.

The only way to get this to work is to make DoFirst and DoSecond virtual methods and use the VirtualMethodInterceptor. Once you do this, then there is no separate proxy, just the derived class, and internal calls will get intercepted.

 

Aug 18, 2010 at 8:10 AM

Many thanks for the response ... at least I know it can be done, it's just my lack of knowledge ... so back to Visual Studio and head scratching  :-)

 

Cheers,

SteveC.

Aug 18, 2010 at 2:50 PM
Edited Aug 18, 2010 at 2:50 PM

Got it working with VirtualMethodInterceptor ... thanks again for the help

 

Cheers,

SteveC