Using method attributes, I get an IEnumerable<Delegate>. I want to call each one, now I use DynamicInvoke and get the result. However, some of the methods can be async and return a Task of something. I don't really care what that something is, I just want serialize it using Newtonsoft.
How can I handle both synchronous and asynchronous methods?
I was thinking of checking if the return type implements Task or Task<T> but since I don't know T I'm not sure this would be a good way of doing it.
Right now, my code does not support asynchronous methods and looks like this:
return JsonConvert.SerializeObject(Method.DynamicInvoke(args));
Aucun commentaire:
Enregistrer un commentaire