mardi 28 février 2017

Using GetCustomAttributes to get all attributes but DataMemberAttributes

I am trying to get custom attributes from a PropertyInfo object, but I am trying to avoid getting DataMemberAttributes. I run into compiler error 'cannot convert from 'object' to 'System.Reflection.MemberInfo'" with the following code:

PropertyInfo myProperty = GetMyProperty(myObject);

object[] myAttributes= fromProperty.GetCustomAttributes(false).Where(a => !Attribute.IsDefined(a, typeof(DataMemberAttribute)));

What would be the correct lambda syntax?





Aucun commentaire:

Enregistrer un commentaire