Jake,
You could try the template method pattern.
public abstract class Abstract
{
private bool m_Flag;
public void DoSomething()
{
if (!m_Flag)
{
DoSomethingConcrete();
}
}
protected abstract void DoSomethingConcrete();
}
public class Concrete
{
protected void DoSomethingConcrete()
{
// Whatever
}
}
I'm not sure this would be feasible in your situation since there would
have to be a template method for each method signature in your
application, but it's the first thing that comes to mind. Aspect
oriented programming might help you as well.
Brian
Jake K wrote:
I have about 100 methods in an application I'm developing. There will be
many, many more methods added as the application grows. I need to include a
line of code at the start of every method in the project and every method
that will be added in the future. The line of code is simply
if (!bSomeVar)
return;
Basically I have to check this bool var before executing the code in the
moethods.
Is there an easy way to inhrit this line or other options?