Last active
January 11, 2017 12:08
-
-
Save emrahyumuk/053dd20e249b9cc887811508fc177dab to your computer and use it in GitHub Desktop.
Run Actions with n parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Main() | |
{ | |
Invoke<List<string>>(Test1, new List<string>()); | |
Invoke<string, int>(Test2, string.Empty, 1); | |
Invoke<string, int, object>(Test3, string.Empty, 1, null); | |
} | |
private static void Invoke<T1>(Action<T1> a, T1 p) | |
{ | |
InvokeMyMethod(a, p); | |
} | |
private static void Invoke<T1, T2>(Action<T1, T2> a, T1 p1, T2 p2 ) | |
{ | |
InvokeMyMethod(a, p1, p2); | |
} | |
private static void Invoke<T1, T2, T3>(Action<T1, T2, T3> a, T1 p1, T2 p2, T3 p3) | |
{ | |
InvokeMyMethod(a, p1, p2, p3); | |
} | |
private static void InvokeMyMethod(Delegate method, params object[] args) | |
{ | |
method.DynamicInvoke(args); | |
} | |
public static void Test1(List<string> t) | |
{ | |
} | |
public static void Test2(string t1, int t2) | |
{ | |
} | |
public static void Test3(string t1, int t2, object t3) | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment