C#属性组 [英] Groups of C# Attributes

查看:112
本文介绍了C#属性组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法来构建一组属性?

Is there any way to build a group of attributes?

[SuppressMessage("Microsoft.Design", "CA1061")]
[SuppressMessage("Microsoft.Usage", "CA1812")]
[SuppressMessage("Microsoft.Design", "CA1064")]
public abstract void Foo();

我要什么:

[SpecialStuff]
public abstract void Foo();

这可能吗?我可以建立一个属性,该属性组别人?

Is this possible? Can I build an attribute that groups others?

推荐答案

的方式属性和它们各自的检查值,通常是通过反射 - 你的特殊综合属性 SpecialDispose 会没有因为它的未知的潜在督察任何意义,所以我不认为它可能实现你想要的。

The way attributes and their respective values are examined is usually through reflection - your special aggregate attribute SpecialDispose would not have any meaning since its unknown to a potential inspector so I do not think its possible to achieve what you want.

这篇关于C#属性组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆