/// <summary>
/// Returns an array of custom attributes applied to this member and identified by <see cref="Type"/>.
/// </summary>
/// <param name="type">
/// The <see cref="System.Type">type</see> to get custom attributes for.
/// </param>
/// <param name="inherit">
/// <c>true</c> to search this member's inheritance chain to find the attributes; otherwise, <c>false</c>.
/// This parameter is ignored for properties and events; see Remarks.
/// </param>
/// <returns>
/// An array that contains all the custom attributes applied to this member,
/// or an array with zero elements if no attributes are defined.
/// </returns>
/// <exception cref="TypeLoadException">
/// A custom attribute type could not be loaded.
/// </exception>
/// <exception cref="ArgumentNullException">
/// If <paramref name="type" /> is <c>null</c>.
/// </exception>
/// <exception cref="InvalidOperationException">
/// This member belongs to a type that is loaded into the reflection-only context.
/// See How to: Load Assemblies into the Reflection-Only Context.
/// </exception>
public static object[] GetCustomAttributes(this Type type, bool inherit)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
return(CustomAttributeExtensions
.GetCustomAttributes(
IntrospectionExtensions.GetTypeInfo(type),
inherit)
.Cast <object>()
.ToArray());
}