Sample code to access attributes on Pocos. There is a single or Multi attribute version to look at
sample call to method
var MutliAttributeList = MyStatic.GetPocoMultiAttribute<MyAttribute>(typeof(poco),"AttrName");
public static UAttribute GetPocoAttribute<TPoco, UAttribute>(string attributeName) {
var result = typeof (TPoco).GetCustomAttributes(true)
.Where(attribute => attribute.GetType()
.Name == attributeName)
.Cast<UAttribute>()
.FirstOrDefault();
return result;
}
public static IEnumerable<UAttribute> GetPocoMultiAttribute<UAttribute>(Type pocoType, string attributeName) {
var result = pocoType.GetCustomAttributes(true)
.Where(attribute => attribute.GetType()
.Name == attributeName).Cast<UAttribute>().ToList();
return result;
}