Unity Interception // Pre- and Post-execution CallHandlers

Feb 7, 2010 at 6:33 PM

In an application I have three call handlers. One of those call handlers needs to be executed before the actual method executes (this is rather easy to accomplish), wheras the other two need to run post-execution. Is there a way to setup the Unity Interception Extension to accomplish this?

Thanks in advance!


Feb 8, 2010 at 1:06 AM

All call handlers are executed as essentially filters, and a handler author chooses how to process. The handler itself is responsible for forwarding the call to the later handlers and even the actual target method.

The general form of a call handler is:

// Do stuff before the actual call

IMethodReturn result = getNext()(input, getNext); // Execute rest of chain/target method

// Do stuff after the call

return result; // Or some other value


So basically, write your handler so it does stuff in the "do stuff after the call" and that's it. There's no specific configuration needed to make this happen.

Feb 8, 2010 at 12:24 PM

Thanks ctavares!