[英]What's ending 'Attribute' in ActionFilterAttribute needed for when filter is being mapped without that word
I've created a new mvc 4 project (razor engine) and I'm not sure of one thing. 我创建了一个新的mvc 4项目(剃刀引擎),但我不确定。
There's a filter: 有一个过滤器:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class InitializeSimpleMembershipAttribute : ActionFilterAttribute
{
...
}
and there's a controller using that filter: 有一个使用该过滤器的控制器:
[InitializeSimpleMembership]
public class AccountController : Controller
{
...
}
Why using InitializeSimpleMembership instead of InitializeSimpleMembershipAttribute is working properly? 为什么使用InitializeSimpleMembership代替InitializeSimpleMembershipAttribute正常工作?
17.1.1 Attribute usage : 17.1.1属性用法 :
The example
这个例子
[Simple] class Class1 {...}
[Simple] interface Interface1 {...}
shows several uses of the Simple attribute.
显示了Simple属性的几种用法。 Although this attribute is defined with the name SimpleAttribute, when this attribute is used, the Attribute suffix may be omitted , resulting in the short name Simple.
尽管此属性是用名称SimpleAttribute定义的,但是当使用此属性时,可以省略Attribute后缀 ,从而导致简称为Simple。 Thus, the example above is semantically equivalent to the following:
因此,以上示例在语义上等效于以下示例:
[SimpleAttribute] class Class1 {...}
[SimpleAttribute] interface Interface1 {...}
Edit: For a extra clarity, in case you were wondering about the naming convention, 17.1 Attribute classes : 编辑:为了更加清楚起见,如果您想知道命名约定, 17.1属性类 :
By convention, attribute classes are named with a suffix of Attribute.
按照约定,属性类以Attribute后缀命名。 Uses of an attribute may either include or omit this suffix.
使用属性可以包含或省略此后缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.