获取部件,其属性是从内部属性构造函数应用? [英] Get member to which attribute was applied from inside attribute constructor?

查看:176
本文介绍了获取部件,其属性是从内部属性构造函数应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义属性,我自定义的构造函数中的属性我想设置我的属性,以我的属性被应用到属性的类型属性的值,在那里好歹访问该成员的属性从我的属性类的内部应用?

I have a custom attribute, inside the constructor of my custom attribute I want to set the value of a property of my attribute to the type of the property my attribute was applied to, is there someway to access the member that the attribute was applied to from inside my attribute class?

推荐答案

属性不工作的方式,我很害怕。他们仅仅是标志,附着于物体,但无法与它们进行交互。

Attributes don't work that way, I'm afraid. They are merely "markers", attached to objects, but unable to interact with them.

属性本身通常应该是缺乏的行为,只是含元数据对于它们所连接的类型。与属性相关联的任何特性应该是由另一个类看起来为属性的presence和执行任务来提供。

Attributes themselves should usually be devoid of behaviour, simply containing meta-data for the type they are attached to. Any behaviour associated with an attribute should be provided by another class which looks for the presence of the attribute and performs a task.

如果您有兴趣的属性应用于类型,这些信息将可在你反映获得属性的同时,

If you are interested in the type the attribute is applied to, that information will be available at the same time you are reflecting to obtain the attribute.

这篇关于获取部件,其属性是从内部属性构造函数应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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