Use Existing Attributes as CallHandlerAttributes

Jan 7, 2009 at 3:04 AM
Let's say i don't want to define my own HandlerAttribute. I want to use an existing attribute, say System.EnterpriseSerivces.TransactionAttribute which has nothing to do with Unity.
And for the methods decorated with this attribute I would like to intercept their calls and wrap them in a transaction. Can this be done?
Jan 7, 2009 at 8:08 AM
It's pretty easy.

Create a custom matching rule that matches the attribute you're looking for, create a call handler that does the transaction stuff, configure them in an interception policy, and you're done.

Actually, I think we already have a matching rule that can look for the presence of an arbitrary attribute - it's late and my memory is fuzzy. If not, it'd be pretty trivial to write.
Jan 8, 2009 at 1:29 AM
beautiful. thanks
In case someone else was wondering about the same thing, here's a link that shows how CustomAttributeMatchingRule (mentioned above) can be used:,guid,72bdda24-0357-4ed9-9f2d-a5d1c884a35b.aspx