I have several static classes in the namespace mySolution.Macros such as
static class Indent{
public static void Run(){
// implementation
}
// other helper methods
}
So my question is how would it be possible to call those methods with the help of reflection?
If the methods were NOT static, then I could do this:
var macroClasses = Assembly.GetExecutingAssembly().GetTypes().Where( x => x.Namespace.ToUpper().Contains("MACRO") );
foreach (var tempClass in macroClasses)
{
var curInstance = Activator.CreateInstance(tempClass);
// I know have an instance of a macro and will be able to run it
// using reflection I can run the method as:
curInstance.GetType().GetMethod("Run").Invoke(curInstance, null);
}
I would like to keep my classes static. How will I be able to do something similar with static methods?
In short I would like to call all the Run methods from all the static classes that are in the namespace mySolution.Macros.