public class Target3<T,T2>
{
T GetTGenericTest(T2 obj);
}
上記のコードでは、GetTGenericTestは GenericMethod ではないためMakeGenericMethod、もちろん使用できません。MethodInfoのオブジェクトに属する がある場合、未定義IInterfaceTarget3<string,int>のバージョンに戻すにはどうすればよいでしょうか? MakeGenericType だけを使用することはできません。現在のMethodInfoものを未定義のものにリンクする方法がないからです。
(短くするための擬似コード)
List<MethodInfo> undefs = new List<MethodInfo>();
void X()
{
Type t = Typeof(Target3<,>);
MethodInfo undefMi = t.GetMethod("GetTGenericTest");
undefs.Add(undefMi);
}
void Y()
{
var obj = new Target3<string,int>();
MethodInfo defMi = obj.GetType().GetMethod("GetTGenericTest");
//How to do this?
MethodInfo undefMi = undefs.FirstOrDefault(u=> defMi.UndefinedVersion() == u);
}