jeudi 22 août 2019

Identify Func<> parameter in method using reflection

I have a collection of methods, and I'd like to identify any that contain a Func<(,,,)> parameter (ideally through reflection).

This would be simple enough by tagging such parameters with [IsFuncAttribute], but I'd like to avoid that approach if possible.

For example, if I had the following method, how could I reliably determine that the third parameter is a Func<,>?

public T MyMethod<T>(T param1, bool param2, Func<t,bool> param3)
{
    // do something
}

Alternatively, being able to identify the third parameter as a delegate with a non void return type would be equally useful.





Aucun commentaire:

Enregistrer un commentaire