/// <summary>
 /// Determines whether the custom attribute of the specified <paramref name="attributeType"/> type or its derived types is applied to the specified <paramref name="parameter"/>.
 /// </summary>
 /// <param name="provider">The reflection provider.</param>
 /// <param name="parameter">The parameter to check the custom attribute on.</param>
 /// <param name="attributeType">The type of attribute to search for.</param>
 /// <returns>true if one or more instances of <paramref name="attributeType" /> or its derived types are applied to the specified <paramref name="parameter"/>; otherwise, false.</returns>
 public static bool IsDefined(this IParameterInfoIntrospectionProvider provider, ParameterInfo parameter, Type attributeType)
 => NotNull(provider).IsDefined(parameter, attributeType, inherit: true);
Exemple #2
0
 /// <summary>
 /// Gets a value indicating whether the specified <paramref name="parameter"/> is a Retval parameter.
 /// </summary>
 /// <param name="provider">The reflection introspection provider.</param>
 /// <param name="parameter">The parameter to check.</param>
 /// <returns>true if the parameter is a Retval parameter; otherwise, false.</returns>
 public static bool IsRetval(this IParameterInfoIntrospectionProvider provider, ParameterInfo parameter) => (NotNull(provider).GetAttributes(parameter) & ParameterAttributes.Retval) > ParameterAttributes.None;
 /// <summary>
 /// Gets the single custom attribute of the specified type <typeparamref name="T"/> applied to the specified <paramref name="parameter"/>.
 /// </summary>
 /// <typeparam name="T">The type of the custom attribute to retrieve.</typeparam>
 /// <param name="provider">The reflection provider.</param>
 /// <param name="parameter">The parameter to get the custom attribute from.</param>
 /// <param name="inherit">Indicates whether or not to retrieve attributes from a base type.</param>
 /// <returns>The single applied custom attribute instance, or null if no such attribute was found.</returns>
 public static T GetCustomAttribute <T>(this IParameterInfoIntrospectionProvider provider, ParameterInfo parameter, bool inherit) where T : Attribute
 => Single(NotNull(provider).GetCustomAttributes <T>(parameter, inherit));
 /// <summary>
 /// Gets the single custom attribute of the specified type applied to the specified <paramref name="parameter"/>.
 /// </summary>
 /// <param name="provider">The reflection provider.</param>
 /// <param name="parameter">The parameter to get the custom attribute from.</param>
 /// <param name="attributeType">The type for which the custom attribute is to be returned. </param>
 /// <param name="inherit">Indicates whether or not to retrieve attributes from a base type.</param>
 /// <returns>The single applied custom attribute instance, or null if no such attribute was found.</returns>
 public static Attribute GetCustomAttribute(this IParameterInfoIntrospectionProvider provider, ParameterInfo parameter, Type attributeType, bool inherit)
 => Single(GetCustomAttributes(provider, parameter, attributeType, inherit));
 /// <summary>
 /// Gets the custom attributes of the specified type <typeparamref name="T"/> applied to the specified <paramref name="parameter"/>.
 /// </summary>
 /// <typeparam name="T">The type of the custom attributes to retrieve.</typeparam>
 /// <param name="provider">The reflection provider.</param>
 /// <param name="parameter">The parameter to get custom attributes from.</param>
 /// <param name="inherit">Indicates whether or not to retrieve attributes from a base type.</param>
 /// <returns>A read-only list of custom attribute instances.</returns>
 public static IReadOnlyList <T> GetCustomAttributes <T>(this IParameterInfoIntrospectionProvider provider, ParameterInfo parameter, bool inherit) where T : Attribute
 => (IReadOnlyList <T>)NotNull(provider).GetCustomAttributes(parameter, typeof(T), inherit);
 /// <summary>
 /// Gets all the custom attributes for the specified <paramref name="parameter"/>.
 /// </summary>
 /// <param name="provider">The reflection provider.</param>
 /// <param name="parameter">The parameter to get custom attributes for.</param>
 /// <param name="inherit">Indicates whether or not to retrieve attributes from a base type.</param>
 /// <returns>An array that contains the custom attributes for the specified <paramref name="parameter"/>.</returns>
 public static IReadOnlyList <Attribute> GetCustomAttributes(this IParameterInfoIntrospectionProvider provider, ParameterInfo parameter, bool inherit)
 => (IReadOnlyList <Attribute>)NotNull(provider).GetCustomAttributes(parameter, typeof(Attribute), inherit);
 /// <summary>
 /// Gets all the custom attributes for the specified <paramref name="parameter"/> as specified by type.
 /// </summary>
 /// <param name="provider">The reflection provider.</param>
 /// <param name="parameter">The parameter to get custom attributes for.</param>
 /// <param name="attributeType">The type for which the custom attributes are to be returned. </param>
 /// <returns>An array that contains the custom attributes for the specified <paramref name="parameter"/>.</returns>
 public static IReadOnlyList <Attribute> GetCustomAttributes(this IParameterInfoIntrospectionProvider provider, ParameterInfo parameter, Type attributeType)
 => (IReadOnlyList <Attribute>)NotNull(provider).GetCustomAttributes(parameter, attributeType, inherit: true);