Is it possible to do the following based on a given type:
var myTypes = new List<Type>();//contains list of classes that implements ISameInterface
public class MyType : ISameInterface
{
public string GetDescription(int num)
{
}
}
var result = new Dictionary<Type, Func<int, string>> ();
this is the idea I have but don't really know how to add the expression created to the dictionary
foreach(var t in myTypes)
{
var exp = Expression.Call(Expression.Constant(Activator.CreateInstance(t),
t.GetMethod("GetDescription"))
result.Add(t, exp????);
}
Aucun commentaire:
Enregistrer un commentaire