1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using SCC.Models;
- namespace SCC.Common
- {
- /// <summary>
- /// 枚举帮助类
- /// </summary>
- public static class EnumHelper
- {
- /// <summary>
- /// 获取彩种对应数据库表名称
- /// </summary>
- /// <param name="value">彩种枚举类型</param>
- /// <returns></returns>
- public static string GetSCCLotteryTableName(Enum value)
- {
- if (value == null)
- {
- throw new ArgumentException("value");
- }
- string TableName = value.ToString();
- var fieldInfo = value.GetType().GetField(TableName);
- var attributes = (TableNameAttribute[])fieldInfo.GetCustomAttributes(typeof(TableNameAttribute), false);
- if (attributes != null && attributes.Length > 0)
- {
- TableName = attributes[0].TableName;
- }
- return TableName;
- }
- }
- }
|