I got a c# method which receives a generic Delegate
as a parameter and after invocation checks the type of the result:
public async Task<TResult> InvokeAction<TResult>(Delegate action, object[] actionArgs = null)
{
...
var result = action.DynamicInvoke(actionArgs);
if (result is Task<TResult> task) return await task;
}
Is there a way I can check in advanced if the return type of the delegate parameter is indeed TResult
without the need to invoke it first? This without changing the parameter the Func<TResult>
Aucun commentaire:
Enregistrer un commentaire