2

我们如何在枚举上定义和使用多重描述属性?

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 = "";
    }
}
4

1 回答 1

5

用 AllowMultiple 装饰属性

[AttributeUsage(AllowMultiple = true)]
class MyAttribute : Attribute {}

更多信息:msdn

于 2012-10-10T20:30:31.850 回答