2

我正在使用 Ninject 在我的自定义授权属性中注入我的依赖项:

public class ValidatePermissionAttribute : AuthorizeAttribute, IAuthorizationFilter
{
    [Inject]
    public IUsuarioRepository UsuarioRepository { get; set; }
}

我的模块:

this.BindFilter<ValidatePermissionAttribute>(FilterScope.Global, null);

我正在尝试搜索有关我的问题的一些文档,但没有找到。

我的问题是关于BindFilter方法中的第二个参数:int? order. 这是什么意思?

我看到的所有示例都有一个0with 参数(就像这个问题Dependency Injection with Ninject and Filter attribute for asp.net mvc)。但在我的情况下,属性注入仅适用于null.

4

1 回答 1

0

它定义了过滤器的执行顺序。首先执行具有较小值的过滤器。

有关详细信息,请参阅http://bradwilson.typepad.com/blog/2010/07/service-location-pt4-filters.html 。

于 2011-09-19T23:43:15.380 回答