Created
March 1, 2014 04:23
-
-
Save baba-s/9285119 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/// <summary> | |
/// リフレクションを使用して名前で指定されたメソッドを呼び出す拡張メソッドを管理するクラス | |
/// </summary> | |
public static class ObjectExtensions2 | |
{ | |
/// <summary> | |
/// 名前で指定されたメソッドを呼び出します | |
/// </summary> | |
public static object Invoke(this object obj, string methodName, params object[] parameters) | |
{ | |
var method = obj.GetType().GetMethod( | |
methodName, | |
BindingFlags.Instance | BindingFlags.Public, | |
null, | |
Array.ConvertAll(parameters, c => c.GetType()), | |
null); | |
return method.Invoke(obj, parameters); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment