我目前正在开发一个需要在运行时公开其一些元数据/文档的系统。我知道有使用XML注释的方法,并通过自行开发的Reflection扩展方法将数据带回到应用程序中。在域实体中使用DescriptionAttribute
我觉得使用System.ComponentModel命名空间的描述属性可能更容易(但位于System assembly中)。这样我和其他开发人员就可以使用正则反射来获取字段的描述。我宁愿使用这个比使用自定义属性。这种方法有什么缺点?
例子:
public Customer
{
public int Id { get; set; }
[Description("The common friendly name used for the customer.")]
public string Name { get; set; }
[Description("The name used for this customer in the existing Oracle ERP system.")]
public string ErpName { get; set; }
}
这更像是一个陈述而非问题。你在问什么? – Romoku 2013-02-26 18:56:25
请尝试http://codereview.stackexchange.com/而不是 – 2013-02-26 19:13:49