I'm following a ninject filter attribute setup on this page.
For them, they have:
.WithConstructorArgumentFromControllerAttribute<LogAttribute>(
"logLevel", attribute => attribute.LogLevel);
The second parameter is expecting a Func<LogAttribute, object> callback
. Their actual param list is setup as follows:
Log(LogLevel = Level.Debug)
But my filter attribute is setup as follows:
public class AuthAttribute : FilterAttribute { }
public class AuthFilter : IAuthorizationFilter
{
private readonly IUserService userService;
private string[] roles;
//Stuck on the constructor also. How do I accept params?
public AuthFilter(IUserService userService, params string[] roles)
{
this.userService = userService;
this.roles = roles;
}
public void OnAuthorization(AuthorizationContext filterContext)
{
throw new NotImplementedException();
}
}
Somehow this is wrong. Because I want my filter to look like:
[Auth("Admin", "Contrib")]
My bindings:
kernel.BindFilter<AuthFilter>(FilterScope.Controller, 0)
.WhenControllerHas<AuthAttribute>()
.WithConstructorArgumentFromControllerAttribute<AuthAttribute>("roles", /*Stuck here*/)