I have a method like this:
public Something MyMethod() { Setup(); Do something useful... TearDown(); return something; }
The Setup and TearDown methods are in the base class.
The problem I am facing is that I have to write this type of method again with the calls to the Setup () method and TearDown () method.
EDIT: The difficult part of this method is that โDoing something useful ...โ refers only to this method. This part is different for every method I create.
In addition, I can have MyMethod2, MyMethod3, in one class. In all cases, I would like to run setup and breaks
Is there an elegant way to do this without having to write it every time?
I may be delusional, but a way to add a method attribute and intercept a method call so that I can do something before and after the call?
source share