We have this pattern everywhere in our code:
using (ServiceAccess ws = new ServiceAccess())
{
//...
//code here to talk to webservice ws
//...
}
How can I replace this boiler plate code with an attribute on the functions that need to talk to the web service? (I'm thinking back to when I did some stuff with Hibernate in Java a long time ago and there was an some "Transation" annotation you could use that would auto-insert some try...catch boiler-plate code into the function.) The using {} is pretty good already but it would be nice to not have it at all... Having an attribute would also help document the function as one that talks the web service as opposed to one that does.
Edit: Would AOP do the trick?