I’m trying to check if a property has the DataMemberAttribute applied (using TypeDescriptor)
this is what I have now:
PropertyDescriptor targetProp = targetProps[i];
var has = argetProp.Attributes.Contains(
Attribute.GetCustomAttribute(typeof(DataMemberAttribute).Assembly,typeof(DataMemberAttribute)));
the problem is that
Attribute.GetCustomAttribute(typeof(DataMemberAttribute).Assembly,typeof(DataMemberAttribute))
returns null
You could use LINQ. A chain of the
.OfType<T>()and.Any()extension methods would do the job just fine: