/// <summary> /// Specifies that the constructor parameter shall be received from an attribute on the controller. /// </summary> /// <typeparam name="TAttribute">The type of the attribute.</typeparam> /// <param name="syntax">The constructor argument syntax.</param> /// <returns>The syntax to specify which value to use.</returns> public static AttributeValueSelector <TAttribute> FromControllerAttribute <TAttribute>(this IConstructorArgumentSyntax syntax) where TAttribute : Attribute { return(new AttributeValueSelector <TAttribute>( syntax.Context.Parameters.OfType <FilterContextParameter>().Single().ActionDescriptor.ControllerDescriptor .GetCustomAttributes <TAttribute>().Single())); }
/// <summary> /// Specifies that the constructor parameter shall be received from an attribute on the action. /// </summary> /// <typeparam name="TAttribute">The type of the attribute.</typeparam> /// <param name="syntax">The constructor argument syntax.</param> /// <returns>The syntax to specify which value to use.</returns> public static AttributeValueSelector <TAttribute> FromActionAttribute <TAttribute>(this IConstructorArgumentSyntax syntax) where TAttribute : Attribute { return(new AttributeValueSelector <TAttribute>( syntax.Context.Parameters.OfType <FilterContextParameter>().Single().ActionDescriptor // use existin impl .GetCustomAttributes(typeof(TAttribute), true).OfType <TAttribute>().Single())); }