【发布时间】:2008-12-24 01:43:04
【问题描述】:
我正在尝试通过 classes 属性上的属性构建对象,该属性指定提供的数据行中作为属性值的列,如下所示:
[StoredDataValue("guid")]
public string Guid { get; protected set; }
[StoredDataValue("PrograGuid")]
public string ProgramGuid { get; protected set; }
在基础对象的 Build() 方法中,我将这些属性上设置的属性值设置为
MemberInfo info = GetType();
object[] properties = info.GetCustomAttributes(true);
但是,在这一点上,我意识到我的知识有限。
首先,我似乎没有恢复正确的属性。
既然有了属性,我该如何通过反射来设置这些属性?我在做/想什么根本不正确的事情吗?
【问题讨论】:
标签: c# reflection