我在通用 DataGrids 中显示业务对象,我想通过自定义属性设置列标题,例如:
class TestBo
{
[Header("NoDisp")]
public int ID {get; set;}
[Header("Object's name")]
public String Name { get; set; }
}
到目前为止,一切都很好,但我还想通过继承将我的显示与我的数据分开:
class TestBO
{
public int ID {get; set;}
public String Name { get; set; }
}
class TestPresentationBO : TestBO
{
//Question: how to simply set the Header attribute on the different properties?
}
我在 Child 构造函数中看到了一个使用 SetCustomAttribute 反射的解决方案,但这会很麻烦,那么这个问题有一个简单而优雅的技巧吗?
请阻止我破坏数据/表示分离;o)