I have a void SubscribeToPublish<TMessage>(Action<TMessage> action)
method. And it expects an Action<T>
. I have an object created purely from Type
in a way like this:
var Node = Activator.CreateInstance(type);
var methods = type.GetMethods(BindingFlags.Public).Where(methodInfo => methodInfo.GetParameters().Count() == 1).ToList();
methods.ForEach(methodInfo => {
SubscribeToPublish(o => methodInfo.Invoke( pair.Value.Node, o )); // Here I see error cannot be inferred from usage.
});
Thus I wonder: how to create Action<T>
on the go having objects created via Reflection?
Aucun commentaire:
Enregistrer un commentaire