123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OASystem.Domain.Enums
- {
- /// <summary>
- /// 月份枚举
- /// </summary>
- public enum MonthEnum
- {
- /// <summary>
- /// 一月
- /// </summary>
- [Description("一月")]
- Jan = 1,
- /// <summary>
- /// 二月
- /// </summary>
- [Description("二月")]
- Feb,
- /// <summary>
- /// 三月
- /// </summary>
- [Description("三月")]
- Mar,
- /// <summary>
- /// 四月
- /// </summary>
- [Description("四月")]
- Apr,
- /// <summary>
- /// 五月
- /// </summary>
- [Description("五月")]
- May,
- /// <summary>
- /// 六月
- /// </summary>
- [Description("六月")]
- Jun,
- /// <summary>
- /// 七月
- /// </summary>
- [Description("七月")]
- Jul,
- /// <summary>
- /// 八月
- /// </summary>
- [Description("八月")]
- Aug,
- /// <summary>
- /// 九月
- /// </summary>
- [Description("九月")]
- Sep,
- /// <summary>
- /// 十月
- /// </summary>
- [Description("十月")]
- Oct,
- /// <summary>
- /// 十一月
- /// </summary>
- [Description("十一月")]
- Nov,
- /// <summary>
- /// 十二月
- /// </summary>
- [Description("十二月")]
- Dec,
- }
-
- static class EnumExtensions
- {
- public static string GetDescription(this Enum val)
- {
- var field = val.GetType().GetField(val.ToString());
- var customAttribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute));
- return customAttribute == null ? val.ToString() : ((DescriptionAttribute)customAttribute).Description;
- }
- }
- }
|