I have a class where every method starts the same way:
internal class Foo {
public void Bar() {
if (!FooIsEnabled) return;
//...
}
public void Baz() {
if (!FooIsEnabled) return;
//...
}
public void Bat() {
if (!FooIsEnabled) return;
//...
}
}
Is there a nice way to require (and hopefully not write each time) the FooIsEnabled
part for every public method in the class?
I check Is there an elegant way to make every method in a class start with a certain block of code?, but that question is for Java, and its answer are using Java Library.