I have a situation below:
public class A{
public IList<B> bs { get; set; }
public C c { get; set;}
}
[CustomAttribute]
public class B{
}
[CustomAttribute]
public class C{
}
I get a list of various entities into an array and then I need to check if any entity's property has custom attribute defined.
for (int i = 0; i < e.Count; i++) {
Type obType = e[i].GetType();
if (!obType.GetCustomAttributes(typeof(CustomAttribute)).Any()) {
/*get all properties which have CustomAttribute defined on its class
- in our case we need to get properties for IList<A> and property for C class*/
}
}
It seems the real problem is to reterive IList object type and retreive custom attribute.
Aucun commentaire:
Enregistrer un commentaire