Exemple #1
0
 /// <summary>
 /// Searches a type/method/property/field for attributes of the specified type, returning the first match.
 /// </summary>
 /// <typeparam name="TAttribute">The type of attribute (may also be a base class).</typeparam>
 /// <param name="member">The type/method/property/field to find attributes on.</param>
 /// <param name="inherit">True to include inherited attributes in the search.</param>
 /// <param name="filter">A filter that restricts the results of the search.</param>
 /// <returns>The first matching attribute instance, or null if no matches are found.</returns>
 public static TAttribute GetAttribute <TAttribute>(MemberInfo member, bool inherit, Predicate <TAttribute> filter)
     where TAttribute : Attribute
 {
     return(CollectionUtils.SelectFirst <TAttribute>(member.GetCustomAttributes(typeof(TAttribute), inherit), filter));
 }