I have a doubt regarding which to use,
1. the usage of the Interception with Unity [ used to add new behaviors for an object at runtime]
2. or to use the policy injection application block in which we can wireup handlers to specific methods on an object.
I am now using unity and want to decide which one is best or efficient. I want to track which resources are being consumed [for specific objects]. For this purpose, which one shall i use 1 or 2.
Whether I can use handlers to dynamically identify the caller and use that to account for a usage or use policy and maintain them separately.
Policy Injection is built on top of Unity interception (assuming you’re using the current versions of Unity / Entlib). Policy Injection is actually implemented as an interception behavior.
Interception behaviors are probably slightly more efficient in that they don’t need to do a lot of complex matching rules to figure out which interceptor to call based on a method call, but they require more work from you if you want to target one to a specific method. Policy injection does more work at setup time, but at call time it’s a wash.
Efficiency isn’t going to be your deciding factor, your overall design and ease of use will. Pick the one you like better.