So I'm working with PostSharp to pull out boilerplate logging/exception handling code so that this:
public void doSomething()
{
Logger.Write("Entered doSomething");
try
{
// code
}
catch (Exception ex)
{
ExceptionPolicy.HandleException(ex, "Errors");
}
Logger.Write("Exited doSomething");
}
becomes this:
[Log]
[HandleExceptions]
public void doSomething()
{
// code
}
but, in certain places I have code that has an instance where known recovery points exist, so it looks like:
public void doSomethig()
{
try
{
// code
}
catch (KnownException ex)
{
ExceptionPolicy.HandleException(ex, "Known");
}
finally
{
this.Recover();
}
}
I'd like to represent this as an advice but I can't seem to get access to members of the class from the advice.