Possible Duplicate:
C# wrap method via attributes
I'd like to achieve such functionality:
[Wrap]
public void Foo()
{
/* foo logic */
}
Where [Wrap]
attribute is an attribute, which wraps function logic within some outer code - just for example let it be a transaction scope:
using(var scope = new TransactionScope())
{
/* foo logic */
scope.Complete();
}
How to write such an attribute ?