I am trying to find out if there is a faster way to achieve the same result of the following code:
{
Type customAttributeType = typeof (CustomAttribute);
MemberInfo[] properties = contract.FindMembers(MemberTypes.Property,
BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
DelegateToSearchCriteria, customAttributeType );
}
static bool DelegateToSearchCriteria(MemberInfo objMemberInfo, Object objSearch)
{
object[] attrs = objMemberInfo.GetCustomAttributes((Type)objSearch, true);
// Compare the name of the member function with the filter criteria.
return attrs.Length > 0;
}
I need to find all the properties with a setter defined, public and not public, with a specific custom attribute.I can't think of anything faster than this. I wonder if there is a better way to do it, for example I know already that I don't need to check value properties, while FindMembers will instead filter them as well.
Aucun commentaire:
Enregistrer un commentaire