When might one use attribute targets?
When might one use attribute prefixes such as class:, return: and module: ?
I haven't yet seen anyone use these prefixe开发者_Go百科s so I was wondering where they could be used.
Example
namespace NameSpace {
class Program {
[return: Description("Returns true if is in a valid state")]
[method: Description("Determines xyz")]
public void IsValid) {
return true;
}
}
Here's a good article which explains where attribute targets could be useful and what problem they address. I remember using those back in the good old days before ASP.NET MVC was out and I was writing some MonoRail applications. The [return: JSONReturnBinder]
allows to specify a binder for the return type of a controller action instead of input parameters.
精彩评论