[reflexion] Verifier un MethodInfo correspond à un delegate
Hello,
j'aimerais une solution pour verifier si la methode decoré d'un attribut "CheckMethode" corresponde bien a un certain delegate ?
(type de retour ,type des parametre et nombres).
le delegate en question
Code:
public delegate bool CheckFunction(Object _obj);
Actuellement j ai ca (ca marche mais ca prend pas en compte le delegate):
dans un constructeur statique, je verifie les types de retour et paramètres des fonction decorée :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
static CCommonSegmentChecker()
{
BindingFlags eFlags = BindingFlags.Instance | BindingFlags.NonPublic;
foreach (var method in typeof(CCommonSegmentChecker).GetMethods(eFlags).Where(met => met.GetCustomAttributes(typeof(CheckMethode), true).Count() != 0))
{
if ((method.ReturnType != typeof(bool)) || (method.GetParameters().Count() != 1))
{
throw new Exception("Bad Check Function");
}
}
} |