1
Faut-il réfléchir?Comment vérifier si un type est marqué avec un attribut?
Faut-il réfléchir?Comment vérifier si un type est marqué avec un attribut?
Oui:
Attribute.IsDefined(yourType, attributeType);
Sauf pour [Serializable]
, qui pourrait aussi êtreyourType.IsSerializable
(si vous cochez la IL, [Serializable]
ne le fait pasfait obtenir écrit comme un attribut - il y a un spécial modificateur de type, l'approche fonctionne bien, cependant).