110,538
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 行政级别大小
/// </summary>
public enum LevelPower
{
/// <summary>
/// 员工
/// </summary>
[Description("员工")]
M1 = 1,
/// <summary>
/// 组长
/// </summary>
[Description("组长")]
M2 = 2,
....
/// <summary>
/// 获取枚举值定义的属性
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
private static EnumAttribute GetAttribute(Enum value)
{
if (enumAttr.ContainsKey(value))
{
EnumAttribute ea = enumAttr[value];
return ea;
}
else
{
FieldInfo field = value.GetType().GetField(value.ToString());
if (field == null) return null;
EnumAttribute ea = null;
object[] attributes = field.GetCustomAttributes(typeof(EnumAttribute), true);
if (attributes != null && attributes.Length > 0)
{
ea = (EnumAttribute)attributes[0];
}
enumAttr[value] = ea;
return ea;
}
}
public enum FairBatchState
{
/// <summary>
/// 生效
/// </summary>
[EnumAttribute("生效")]
Enable=1,
/// <summary>
/// 无效
/// </summary>
[EnumAttribute("无效")]
Disable=0
}