Is it possible to do that in C# 3 or 4? Maybe with some reflection?
class Magic
{
[RunBeforeAll]
public void BaseMethod()
{
}
//runs Ba
There is an alternate solution for this, make Magic a singleton and put your code on the getter of the static instance. That's what i did.
public class Magic{
private static Magic magic;
public static Magic Instance{
get
{
BaseMethod();
return magic;
}
}
public void BaseMethod(){
}
//runs BaseMethod before being executed
public void Method1(){
}
//runs BaseMethod before being executed
public void Method2(){
}
}