12
I have several methods that look like this:
public void foo()
{
try
{
doSomething();
}
catch(Exception e)
{
Log.Error(e);
}
}
Can I change the code to look like?
[LogException()]
public void foo()
{
doSomething();
}
How can I implement this custom attribute? and what are the pros and cons of doing it?
-----Edit 1------------
Can I implemented it myself, I mean just write one class, or do I need to use postsharp or another solution?