/// <summary> /// Tries to get the associated attribute for a given object type. /// </summary> /// <typeparam name="TAttribute"></typeparam> /// <param name="objectType">The object type.</param> /// <param name="attribute">The attribute.</param> /// <param name="inherit">A boolean flag to search the type's inheritance chain to find the attribute.</param> /// <returns>Returns the associated attribute for the given object-type.</returns> public static bool TryGetTypeAttribute <TAttribute>(Type objectType, out TAttribute attribute, bool inherit = false) where TAttribute : Attribute { if (AttributedTypeResolver <TAttribute> .HasCurrent == false) { AttributedTypeResolver <TAttribute> .Current = AttributedTypeResolver <TAttribute> .Create(new[] { objectType }, inherit); } return(AttributedTypeResolver <TAttribute> .Current.TryGetTypeAttribute(objectType, out attribute, inherit)); }