/// <summary> /// Gets the type of the attribute for. /// </summary> /// <typeparam name="TAttribute">The type of the attribute.</typeparam> /// <typeparam name="TType">The type of the type.</typeparam> /// <param name="property">The property.</param> /// <param name="type">The type.</param> /// <param name="predicate">The predicate.</param> /// <returns>Returns an Attribute</returns> public static TAttribute GetAttribute <TAttribute, TType>(PropertyInfo property = null, TType type = null, Func <TAttribute, bool> predicate = null) where TAttribute : Attribute where TType : class { Type desiredType = type == null ? typeof(TType) : type.GetType(); CachedTypeData cacheType = ReflectedCache.TypePropertyCache.GetOrAdd(desiredType, new CachedTypeData(desiredType)); return(cacheType.GetAttribute <TAttribute>(property, predicate)); }
/// <summary> /// Gets the single attribute for Type. /// </summary> /// <param name="type">The type.</param> /// <param name="property">The property.</param> /// <param name="predicate">The predicate.</param> /// <returns>Returns an Attribute</returns> public static Attribute GetAttribute(Type type, PropertyInfo property = null, Func <Attribute, bool> predicate = null) { CachedTypeData cacheType = ReflectedCache.TypePropertyCache.GetOrAdd(type, new CachedTypeData(type)); return(cacheType.GetAttribute(property, predicate)); }