简体   繁体   English

当过滤器在没有单词的情况下映射时,所需的ActionFilterAttribute的“ Attribute”结尾是什么

[英]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.

相关问题 在 ActionFilterAttribute 中查找过滤器 - Finding a filter in ActionFilterAttribute 没有MVC的ActionFilterAttribute行为 - ActionFilterAttribute behavior without MVC 什么是属性中的“property:” - What is word “property:” in Attribute 什么时候覆盖ActionFilterAttribute.OnActionExecutingAsync()? - When to override ActionFilterAttribute.OnActionExecutingAsync()? 当'用户映射部分打开的文件无法执行请求的操作时'出了什么问题?' - What's wrong when 'the requested operation cannot be performed on a file with a user-mapped section open?' 是什么导致我的收藏集无法与AutoMapper(5.x)映射? - What is preventing my collections from being mapped with AutoMapper (5.x)? C#ActionFilterAttribute什么是默认的AttributeUsage - C# ActionFilterAttribute what is default AttributeUsage 从ActionFilterAttribute返回带有它的模型的视图 - Returning a view with it's model from an ActionFilterAttribute 有没有办法将控制器的ModelState传递(或访问)到ActionFilterAttribute? - Is there a way to pass (or access) a controller's ModelState to an ActionFilterAttribute? 在请求过滤器中结束响应时,ServiceStack设置响应DTO - ServiceStack set Response DTO when ending the response in Request Filter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM