In my WPF MVVM project I have to execute some 10 methods in one go without passing individual name one by one. Lets say I can do this for a single method call:
CallStaticMethod("MainApplication.Test", "Test1");
its body:
public static void CallStaticMethod(string typeName, string methodName)
{
var type = Type.GetType(typeName);
if (type != null)
{
var method = type.GetMethod(methodName);
if (method != null)
{
method.Invoke(null, null);
}
}
}
public static class Test
{
public static void Test1()
{
Console.WriteLine("Test invoked");
}
}
But I have the requirement:
public static class Test
{
public static void Test1()
{
Console.WriteLine("Test invoked");
}
public static void Test2()
{
Console.WriteLine("Test invoked");
}
public static void Test3()
{
Console.WriteLine("Test invoked");
}
public static void CallAllTestMethod()
{
Test1();
Test2();
Test3();
}
}
Now I want to call this CallAllTestMethod()
and also want to know which method (Test1
,Test2
or Test3
) is currently being processed. Any thought on this?