我们如何在Enum上定义和使用多个描述属性?
public enum EnumWithDescription
{
[CustomDescritption("job-view")]
[Description("analyics-job-view")]
JobView
}
class CustomDescritption: DescriptionAttribute
{
private string extraInfo;
public string ExtraInfo { get { return extraInfo; } set { extraInfo = value; } }
public MyDescritptionAttribute(string description)
{
this.DescriptionValue = description;
this.extraInfo = "";
}
}
答案 0 :(得分:5)
使用AllowMultiple
装饰属性[AttributeUsage(AllowMultiple = true)]
class MyAttribute : Attribute {}
更多信息:msdn