CSharp examples for System.Reflection:PropertyInfo
Search Property Info From Attribute
using System.Reflection; using System.Linq; using System;/*from ww w . ja v a2s. c o m*/ public class Main{ public static PropertyInfo SearchPropertyInfoFromAttribute<TAttribute>(Type type) where TAttribute:Attribute { foreach (var propertyInfo in type.GetProperties()) { object[] attributes = propertyInfo.GetCustomAttributes(typeof (TAttribute), true); if (attributes.Length == 1) return propertyInfo; } return null; } }