创建枚举 - SlowX.CreateEnumApp(2017.07.18)

2017-07-18 11:42:38  访问(2320) 赞(0) 踩(0)


相关下载:SlowX.CreateEnumApp(执行程序)  SlowX.CreateEnumApp(源码)      查看源码:SlowX.CreateEnumApp     



  • 
    
    
    /*
    
    管理员 = 1
    普通用户
    
    // 枚举拼串用于复制粘贴 //
    管理员/普通用户
    
    */
    
    using System; 
    
    
    namespace SlowX.UserLib.Enums
    {
        /// <summary>
        /// 用户角色
        /// </summary>
        /// 说明:
        /// 1、由代码生成工具SlowX.CreateEnumApp刷新生成
        /// 2、本cs文件后续如有升级需要,可以手动修改
        /// 3、主要修改的内容:
        /// (1)、EmUserRole的枚举项
        /// (2)、EmArrayBuild的枚举数组项
        /// 
        [Serializable]
        public partial class UserRole  
        {
    
            /// <summary>
            /// 用户角色
            /// </summary>
            public UserRole()
            {
                // 管理员/普通用户
            }
    
            #region Enum - EmUserRole
    
            /// <summary>
            /// 用户角色 -- 管理员/普通用户
            /// </summary>
            public enum EmUserRole
            {
    
                /// <summary>
                /// 管理员
                /// </summary>
                管理员 = 1,
                /// <summary>
                /// 普通用户
                /// </summary>
                普通用户
            }
    
            #endregion Enum - EmUserRole
    
            /// <summary>
            /// 数组 - EmUserRole[]
            /// </summary>
            protected static EmUserRole[] m_EmArray = null;
    
            /// <summary>
            /// 数组 - EmUserRole[]
            /// </summary>
            public static EmUserRole[] EmArray
            {
                get
                {
                    if(m_EmArray == null)
                    {
                        m_EmArray = EmArrayBuild();
                    }
    
                    return m_EmArray;
                }
            }
    
            /// <summary>
            /// 构建枚举EmUserRole -- 管理员/普通用户的数组
            /// </summary>
            /// <returns></returns>
            public static EmUserRole[] EmArrayBuild()
            {
                return new EmUserRole[]
                {
                    EmUserRole.管理员,
        EmUserRole.普通用户
        
                }; 
            }
        }
    }
    
    
    
  • 
    
    /*
    
    管理员 = 1
    普通用户
    
    // 枚举拼串用于复制粘贴 //
    管理员/普通用户
    
    */
    
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Reflection;
    
    
    using SlowX.Core.Classes.CacheItems;
    using SlowX.Core.Model;
    
    
    namespace SlowX.UserLib.Enums
    {
        /// <summary>
        /// 用户角色 -- 管理员/普通用户
        /// </summary>
        /// 说明:
        /// 1、由代码生成工具SlowX.CreateEnumApp刷新生成
        /// 2、本cs文件后续如有升级需要,可以手动修改
        /// 3、主要修改的内容:
        /// (1)、GetShowName(em, showCode);
        /// 
        public partial class UserRole 
            :
            SlowX.Core.BaseEnums.BaseCoreEnum
             
        {
            // 用户角色 //
            #region 需要改动的代码区域
    
            /// <summary>
            /// 默认的枚举值
            /// </summary>
            public static EmUserRole defaultEm
            {
                get
                {
                    return EmUserRole.管理员;
                }
            }
    
            #region 显示名称
    
            /// <summary>
            /// 获得显示名称
            /// </summary>
            /// <param name="em">枚举值</param>
            /// <returns></returns>
            public static string GetShowName
                (
                    EmUserRole em
                )
            {
                return em.ToString();
            }
    
    
            /// <summary>
            /// 缺省是em.ToString(),如有需要通过showCode切换显示
            /// </summary>
            /// <param name="em">枚举值</param>
            /// <param name="showCode">显示代号</param>
            /// <returns></returns>
            public static string GetShowName
                (
                    EmUserRole em,
                    string showCode
                )
            {
                return em.ToString();
            }
    
    
            #endregion 显示名称
    
            #endregion 需要改动的代码区域 
    
    
            /// <summary>
            /// DLL名称:SlowX.UserLib
            /// </summary>
            public const string DLLName = "SlowX.UserLib";
    
            /// <summary>
            /// 逻辑类:SlowX.UserLib.Enums.UserRole
            /// </summary>
            public const string ClassName = "SlowX.UserLib.Enums.UserRole";
    
    
            ///// <summary>
            ///// $Em.UserRole
            ///// </summary>
            //public const string _SortClassName = "$Em.UserRole";
    
    
            ///// <summary>
            ///// typeof(UserRole) 当前UserRole的type值
            ///// </summary>
            //public readonly static Type curType = typeof(UserRole);
    
            ///// <summary>
            ///// typeof(UserRole).FullName 
            ///// </summary>
            //public readonly static string curTypeFullName = curType.FullName;
    
    
            ///// <summary>
            ///// typeof(EmUserRole) 当前枚举EmUserRole的type值
            ///// </summary>
            //public readonly static Type curEnumType = typeof(EmUserRole);
    
            ///// <summary>
            ///// typeof(EmUserRole).FullName
            ///// </summary>
            //public readonly static string curEnumTypeFullName = curEnumType.FullName;
    
    
            
            #region 静态实体 和 继承相关
    
            /// <summary>
            /// 静态实体
            /// </summary>
            public readonly static UserRole instance = new UserRole();
    
    
            /// <summary>
            /// 通过Int获得枚举
            /// </summary>
            /// <param name="theValue">枚举对应的int值,一般是(int)emXX</param>
            /// <returns></returns>
            public EmUserRole EmGetByInt(int theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((int)em == theValue)
                        return em;
                }
                
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> " 
                        + methodBaseValue.ReflectedType.FullName 
                        + " ~ " 
                        + methodBaseValue.ToString() 
                        + " Exception :==> " 
                        + "theValue = " 
                        + theValue.ToString() 
                        + "没有找到对应的枚举值。"
                    );
            }
    
    
            /// <summary>
            /// 通过Long值(long)emXX的值获得枚举
            /// </summary>
            /// <param name="theValue">枚举对应的long值,一般是(long)emXX</param>
            /// <returns></returns>
            public EmUserRole EmGetByLong(long theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((long)em == theValue)
                        return em;
                }
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> "
                        + methodBaseValue.ReflectedType.FullName
                        + " ~ "
                        + methodBaseValue.ToString()
                        + " Exception :==> "
                        + "theValue = "
                        + theValue.ToString()
                        + "没有找到对应的枚举值。"
                    );
            }
    
    
            /// <summary>
            /// 通过String值((int)emXX).ToString()的值获得枚举
            /// </summary>
            /// <param name="theValue">枚举对应的string值,一般是((int)emXX).ToString()</param>
            /// <returns></returns>
            public EmUserRole EmGetByStr(string theValue)
            {
                if (theValue == null || theValue.Length == 0)
                {
    
                    throw new Exception
                        (
                            "方法:"
                            + MethodBase.GetCurrentMethod().ReflectedType.FullName
                            + " "
                            + MethodBase.GetCurrentMethod().ToString()
                            + " 发生异常:"
                            + "传入的字符串参数:"
                            + "theValue"
                            + "为null或为空。"
                        );
                }
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return em;
                }
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> "
                        + methodBaseValue.ReflectedType.FullName
                        + " ~ "
                        + methodBaseValue.ToString()
                        + " Exception :==> "
                        + "theValue = "
                        + theValue.ToString()
                        + "没有找到对应的枚举值。"
                    );
            }
    
    
            /// <summary>
            /// 通过Int获得枚举
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public EmUserRole EmGetDefaultByInt(int theValue,EmUserRole defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((int)em == theValue)
                        return em;
                }
    
                return defaultValue;
            }
    
    
            /// <summary>
            /// 通过Long获得枚举
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public EmUserRole EmGetDefaultByLong(long theValue, EmUserRole defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((long)em == theValue)
                        return em;
                }
    
                return defaultValue;
            }
    
    
            /// <summary>
            /// 通过String获得枚举
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public EmUserRole EmGetDefaultByStr(string theValue, EmUserRole defaultValue)
            {
                if (theValue == null || theValue.Length == 0)
                {
                    return defaultValue;
                }
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return em;
                }
    
                return defaultValue;
            }
    
            /// <summary>
            /// 通过String判断Value或Text获得枚举
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public EmUserRole EmFullGetByStr(string theValue, EmUserRole defaultValue)
            {
                if (theValue == null || theValue.Length == 0)
                {
    
                    throw new Exception
                        (
                            "方法:"
                            + MethodBase.GetCurrentMethod().ReflectedType.FullName
                            + " "
                            + MethodBase.GetCurrentMethod().ToString()
                            + " 发生异常:"
                            + "传入的字符串参数:"
                            + "theValue"
                            + "为null或为空。"
                        );
                }
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return em;
                }
    
                foreach (EmUserRole em in emA)
                {
                    if (em.ToString() == theValue)
                        return em;
                }
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> "
                        + methodBaseValue.ReflectedType.FullName
                        + " ~ "
                        + methodBaseValue.ToString()
                        + " Exception :==> "
                        + "theValue = "
                        + theValue.ToString()
                        + "没有找到对应的枚举值。"
                    );
            }
    
            /// <summary>
            /// 通过String判断Value或Text获得枚举
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public EmUserRole EmFullGetDefaultByStr(string theValue, EmUserRole defaultValue)
            {
                if (theValue == null || theValue.Length == 0)
                {
                    return defaultValue;
                }
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return em;
                }
    
    
                foreach (EmUserRole em in emA)
                {
                    if (em.ToString() == theValue)
                        return em;
                }
    
                return defaultValue;
            }
    
    
    
            /// <summary>
            /// 获得枚举对应的返回数据集
            /// </summary>
            /// <returns></returns>
            public override DataTable B_ReturnDataTable()
            {
                return ReturnDataTable();
            }
    
    
            /// <summary>
            /// 获得枚举对应的返回数据集 - CoreDataListItem
            /// </summary>
            /// <returns></returns>
            public override CoreDataListItem B_ReturnDataListItem()
            {
                return ReturnDataListItem();
            }
    
            /// <summary>
            /// 通过Int判断是否是枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public override bool B_IsEnumByInt(int theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((int)em == theValue)
                        return true;
                }
    
                return false;
            }
    
            /// <summary>
            /// 通过long判断是否是枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public override bool B_IsEnumByLong(long theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((long)em == theValue)
                        return true;
                }
    
                return false;
            }
    
            /// <summary>
            /// 通过string判断是否是枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public override bool B_IsEnumByStr(string theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return true;
                }
    
                return false;
            }
    
            /// <summary>
            /// 通过Int值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByInt(int theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((int)em == theValue)
                        return GetShowName(em);
                }
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> "
                        + methodBaseValue.ReflectedType.FullName
                        + " ~ "
                        + methodBaseValue.ToString()
                        + " Exception :==> "
                        + "theValue = "
                        + theValue.ToString()
                        + "没有找到对应的枚举值。"
                    );
            }
    
    
            /// <summary>
            /// 通过Int值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByInt(int theValue, string defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((int)em == theValue)
                        return GetShowName(em);
                }
    
                return defaultValue;
            }
    
    
            /// <summary>
            /// 通过Int值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param> 
            /// <param name="throwException"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByInt(int theValue, bool throwException)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((int)em == theValue)
                        return GetShowName(em);
                }
    
                if (throwException)
                {
                    MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> "
                            + methodBaseValue.ReflectedType.FullName
                            + " ~ "
                            + methodBaseValue.ToString()
                            + " Exception :==> "
                            + "theValue = "
                            + theValue.ToString()
                            + "没有找到对应的枚举值。"
                        );
                }
                else
                {
                    return "";
                }
            }
    
            /// <summary>
            /// 通过Int值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="throwException"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByInt(int theValue, bool throwException, string defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((int)em == theValue)
                        return GetShowName(em);
                }
    
                if (throwException)
                {
                    MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> "
                            + methodBaseValue.ReflectedType.FullName
                            + " ~ "
                            + methodBaseValue.ToString()
                            + " Exception :==> "
                            + "theValue = "
                            + theValue.ToString()
                            + "没有找到对应的枚举值。"
                        );
                }
                else
                {
                    return defaultValue;
                }
            }
    
    
            /// <summary>
            /// 通过Long值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByLong(long theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((long)em == theValue)
                        return GetShowName(em);
                }
    
                 
                    MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> "
                            + methodBaseValue.ReflectedType.FullName
                            + " ~ "
                            + methodBaseValue.ToString()
                            + " Exception :==> "
                            + "theValue = "
                            + theValue.ToString()
                            + "没有找到对应的枚举值。"
                        );
                 
            }
    
            /// <summary>
            /// 通过Long值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByLong(long theValue, string defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((long)em == theValue)
                        return GetShowName(em);
                }
    
    
                return defaultValue;
            }
    
            /// <summary>
            /// 通过Long值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="throwException"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByLong(long theValue, bool throwException)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((long)em == theValue)
                        return GetShowName(em);
                }
    
                if (throwException)
                {
                    MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> "
                            + methodBaseValue.ReflectedType.FullName
                            + " ~ "
                            + methodBaseValue.ToString()
                            + " Exception :==> "
                            + "theValue = "
                            + theValue.ToString()
                            + "没有找到对应的枚举值。"
                        );
                }
                else
                {
                    return "";
                }
            }
    
            /// <summary>
            /// 通过Long值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="throwException"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByLong(long theValue, bool throwException, string defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if ((long)em == theValue)
                        return GetShowName(em);
                }
    
                if (throwException)
                {
                    MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> "
                            + methodBaseValue.ReflectedType.FullName
                            + " ~ "
                            + methodBaseValue.ToString()
                            + " Exception :==> "
                            + "theValue = "
                            + theValue.ToString()
                            + "没有找到对应的枚举值。"
                        );
                }
                else
                {
                    return defaultValue;
                }
            }
    
            /// <summary>
            /// 通过String值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByStr(string theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return GetShowName(em);
                }
    
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> "
                        + methodBaseValue.ReflectedType.FullName
                        + " ~ "
                        + methodBaseValue.ToString()
                        + " Exception :==> "
                        + "theValue = "
                        + theValue.ToString()
                        + "没有找到对应的枚举值。"
                    );
            }
    
            /// <summary>
            /// 通过String值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByStr(string theValue, string defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return GetShowName(em);
                }
    
    
                return defaultValue;
            }
    
            /// <summary>
            /// 通过String值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="throwException"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByStr(string theValue, bool throwException)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return GetShowName(em);
                }
    
                if (throwException)
                {
                    MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> "
                            + methodBaseValue.ReflectedType.FullName
                            + " ~ "
                            + methodBaseValue.ToString()
                            + " Exception :==> "
                            + "theValue = "
                            + theValue.ToString()
                            + "没有找到对应的枚举值。"
                        );
                }
                else
                {
                    return "";
                }
            }
    
    
            /// <summary>
            /// 通过String值获得对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="throwException"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextByStr(string theValue, bool throwException, string defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (((int)em).ToString() == theValue)
                        return GetShowName(em);
                }
    
                if (throwException)
                {
                    MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> "
                            + methodBaseValue.ReflectedType.FullName
                            + " ~ "
                            + methodBaseValue.ToString()
                            + " Exception :==> "
                            + "theValue = "
                            + theValue.ToString()
                            + "没有找到对应的枚举值。"
                        );
                }
                else
                {
                    return defaultValue;
                }
            }
    
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids
                )
            {
                return B_GetEnumTextsByIds(ids, ",", "/", true, "");
            }
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <param name="valueLinkChar"></param>
            /// <param name="textLinkChar"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids,
                    string valueLinkChar,
                    string textLinkChar
                )
            {
                return B_GetEnumTextsByIds(ids, valueLinkChar, textLinkChar, true, "");
            }
    
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <param name="throwException"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids,
                    bool throwException
                )
            {
                return B_GetEnumTextsByIds(ids, ",", "/", throwException, "");
            }
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <param name="valueLinkChar"></param>
            /// <param name="textLinkChar"></param>
            /// <param name="throwException"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids,
                    string valueLinkChar,
                    string textLinkChar,
                    bool throwException
                )
            {
                return B_GetEnumTextsByIds(ids, valueLinkChar, textLinkChar, throwException, "");
            }
    
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids,
                    string defaultValue
                )
            {
                return B_GetEnumTextsByIds(ids, ",", "/", false, defaultValue);
            }
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <param name="valueLinkChar"></param>
            /// <param name="textLinkChar"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids,
                    string valueLinkChar,
                    string textLinkChar,
                    string defaultValue
                )
            {
                return B_GetEnumTextsByIds(ids, valueLinkChar, textLinkChar, false, defaultValue);
            }
    
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <param name="throwException"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids,
                    bool throwException,
                    string defaultValue
                )
            {
                return B_GetEnumTextsByIds(ids, ",", "/", throwException, defaultValue);
            }
    
            /// <summary>
            /// 通过Ids获得枚举的拼串
            /// </summary>
            /// <param name="ids"></param>
            /// <param name="valueLinkChar"></param>
            /// <param name="textLinkChar"></param>
            /// <param name="throwException"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public override string B_GetEnumTextsByIds
                (
                    string ids,
                    string valueLinkChar,
                    string textLinkChar,
                    bool throwException,
                    string defaultValue
                )
            {
                if (ids == null || ids.Length == 0)
                    return "";
                
                if (valueLinkChar == null)
                    valueLinkChar = ",";
    
                if (textLinkChar == null)
                    textLinkChar = "";
    
                string[] sA = ids.Split(valueLinkChar.ToCharArray());
    
                if (sA == null || sA.Length == 0)
                    return "";
    
                StringBuilder theResult = new StringBuilder();
                bool isFirst = true;
                string strTmp = null;
    
                foreach (string s in sA)
                {
                    if (s == null || s.Length == 0)
                        continue;
    
                    strTmp = B_GetEnumTextByStr(s.Trim(), throwException, defaultValue);
    
                    if (strTmp == null || strTmp.Length == 0)
                        continue;
    
                    if (isFirst)
                        isFirst = false;
                    else
                        theResult.Append(textLinkChar);
    
                    theResult.Append(strTmp);
                }
    
                return theResult.ToString();
            }
    
    
    
            #endregion 静态实体 和 继承相关
    
    
    
            #region DataTable相关
    
            /// <summary>
            /// 默认的DataTable值
            /// </summary>
            protected static DataTable DefaultDataTable = null;
    
            /// <summary>
            /// 创建枚举对应的DataTable(ID,TheName)
            /// </summary>
            /// <returns></returns>
            public static DataTable CreateDataTable()
            {
                DataTable dt = new DataTable();
    
                dt.Columns.Add("ID", typeof(int));
                dt.Columns.Add("TheName");
    
                EmUserRole[] emA = EmArray;
    
                DataRow dr = null;
    
                foreach (EmUserRole em in emA)
                {
                    dr = dt.NewRow();
    
                    dt.Rows.Add(dr);
    
                    dr["ID"] = (int)em;
                    dr["TheName"] = GetShowName(em);
                }
    
                return dt;
            }
    
            /// <summary>
            ///  创建枚举对应的DataTable(ID,TheName)
            /// </summary>
            /// <param name="showCode">显示代号</param>
            /// <returns>DataTable(ID,TheName)</returns>
            public static DataTable CreateDataTableByShowCode
                (
                    string showCode
                )
            {
                DataTable dt = new DataTable();
    
                dt.Columns.Add("ID", typeof(int));
                dt.Columns.Add("TheName");
    
                EmUserRole[] emA = EmArray;
    
                DataRow dr = null;
    
                foreach (EmUserRole em in emA)
                {
                    dr = dt.NewRow();
    
                    dt.Rows.Add(dr);
    
                    dr["ID"] = (int)em;
                    dr["TheName"] = GetShowName(em, showCode);
                }
    
                return dt;
            }
    
            /// <summary>
            /// 获得枚举对应的DataTable(主要用于绑定)
            /// </summary>
            /// <returns>如果DefaultDataTable为null,创建并赋值DefaultDataTable,返回DefaultDataTable</returns>
            public static DataTable ReturnDataTable()
            {
                if (DefaultDataTable == null)
                    DefaultDataTable = CreateDataTable();
    
                return DefaultDataTable;
            }
    
            /// <summary>
            /// 获得枚举对应的DataTable(主要用于绑定)
            /// </summary>
            /// <returns>如果DefaultDataTable为null,创建并赋值DefaultDataTable,返回DefaultDataTable</returns>
            public static DataTable GetDataTable()
            {
                if (DefaultDataTable == null)
                    DefaultDataTable = CreateDataTable();
    
                return DefaultDataTable;
            }
    
            #endregion DataTable相关
    
    
            
            #region CoreDataListItem 相关
    
            /// <summary>
            /// CoreDataListItem 模式的数据源
            /// </summary>
            private static CoreDataListItem DefaultDataListItem = null;
    
    
            /// <summary>
            /// 创建 - CoreDataListItem
            /// </summary> 
            /// <returns></returns>
            private static List<BaseModel> CreateBaseModelList
                (
    
                )
            {
                List<BaseModel> theResult = new List<BaseModel>();
                EmUserRole[] emA = EmArray;
    
                BasicDataModel model = null;
    
                foreach (EmUserRole em in emA)
                {
                    model = new BasicDataModel();
                    model.ID = (long)em;
                    model.TheName = GetShowName(em);
    
                    theResult.Add(model);
                }
    
                return theResult;
            }
    
    
            /// <summary>
            /// 创建CoreDataListItem模式的数据源
            /// </summary>
            /// <returns></returns>
            public static CoreDataListItem CreateDataListItem()
            {
                CoreDataListItem theResult = new CoreDataListItem();
    
                theResult.EmDataIsTreeV 
                    = 
                    SlowX.Core.Enums.DataIsTree.EmDataIsTree.否;
    
                theResult.TreeLayer = 1;
                theResult.DataList = CreateBaseModelList();
                theResult.TreeList = theResult.DataList;
    
                return theResult;
            }
    
    
            /// <summary>
            /// 创建 - CoreDataListItem
            /// </summary> 
            /// <param name="showCode">显示代号</param>
            /// <returns></returns>
            private static List<BaseModel> CreateBaseModelListByShowCode
                (
                    string showCode
                )
            {
                List<BaseModel> theResult = new List<BaseModel>();
                EmUserRole[] emA = EmArray;
    
                BasicDataModel model = null;
    
                foreach (EmUserRole em in emA)
                {
                    model = new BasicDataModel();
                    model.ID = (long)em;
                    model.TheName = GetShowName(em, showCode);
    
                    theResult.Add(model);
                }
    
                return theResult;
            }
    
    
            /// <summary>
            /// 创建CoreDataListItem模式的数据源
            /// </summary>
            /// <param name="showCode">显示代号</param>
            /// <returns></returns>
            public static CoreDataListItem CreateDataListItemByShowCode(string showCode)
            {
                CoreDataListItem theResult = new CoreDataListItem();
    
                theResult.EmDataIsTreeV
                    =
                    SlowX.Core.Enums.DataIsTree.EmDataIsTree.否;
    
                theResult.TreeLayer = 1;
                theResult.DataList = CreateBaseModelListByShowCode(showCode);
                theResult.TreeList = theResult.DataList;
    
                return theResult;
            }
    
    
            /// <summary>
            /// 获得枚举对应的CoreDataListItem(主要用于绑定)
            /// </summary>
            /// <returns></returns>
            public static CoreDataListItem ReturnDataListItem()
            {
                if (DefaultDataListItem == null)
                    DefaultDataListItem = CreateDataListItem();
    
                return DefaultDataListItem;
            }
    
            /// <summary>
            /// 获得枚举对应的CoreDataListItem(主要用于绑定)
            /// </summary>
            /// <returns></returns>
            public static CoreDataListItem GetDataListItem()
            {
                if (DefaultDataListItem == null)
                    DefaultDataListItem = CreateDataListItem();
    
                return DefaultDataListItem;
            }
    
            #endregion CoreDataListItem 相关
    
    
    
            #region 值数组
    
            /// <summary>
            /// 获得Value的int[]数组
            /// </summary>
            /// <returns></returns>
            public static int[] GetValueArray()
            {
                EmUserRole[] emA = EmArray;
                int iLen = emA.Length;
                int[] theResult = new int[iLen];
    
                for (int i = 0; i < iLen; ++i)
                {
                    theResult[i] = (int)emA[i];
                }
    
                return theResult;
            }
    
            /// <summary>
            /// 获得Text的string[]数组
            /// </summary>
            /// <returns></returns>
            public static string[] GetTextArray()
            {
                EmUserRole[] emA = EmArray;
                int iLen = emA.Length;
                string[] theResult = new string[iLen];
    
                for (int i = 0; i < iLen; ++i)
                {
                    theResult[i] = GetShowName(emA[i]);
                }
    
                return theResult;
            }
    
            #endregion 值数组
    
            #region 获得显示的名称的拼串 - GetShowNames
    
            /// <summary>
            /// 获得显示的名称的拼串
            /// </summary>
            /// <param name="strValues">输入值,形如value,value,value</param>
            /// <param name="valueLinkChar">值的链接符,如,</param>
            /// <param name="textLinkChar">显示text的链接符,如/</param>
            /// <returns>text/text/text模式</returns>
            public static string GetShowNames
                (
                    string strValues,
                    string valueLinkChar,
                    string textLinkChar
                )
            {
                if (strValues == null || strValues.Length == 0)
                    return "";
    
                if (valueLinkChar == null || valueLinkChar.Length == 0)
                    valueLinkChar = ",";
    
                string[] sArray 
                    = 
                    strValues.Split(valueLinkChar.ToCharArray());
    
                StringBuilder theResult = new StringBuilder();
                bool isFirst = true;
    
                foreach (string s in sArray)
                {
                    if (s == null || s.Length == 0)
                        continue;
    
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        theResult.Append(textLinkChar);
                    }
    
                    theResult.Append
                        (
                            GetShowName
                                (
                                    GetEmByString(s) 
                                )
                        );
                }
    
                return theResult.ToString();
            }
    
            /// <summary>
            /// 获得显示的名称的拼串
            /// </summary>
            /// <param name="strValues">输入值,形如value,value,value</param>
            /// <param name="valueLinkChar">值的链接符,如,</param>
            /// <param name="textLinkChar">显示text的链接符,如/</param>
            /// <param name="showCode">显示代号</param>
            /// <returns>text/text/text模式</returns>
            public static string GetShowNames
                (
                    string strValues,
                    string valueLinkChar,
                    string textLinkChar,
                    string showCode
                )
            {
                if (strValues == null || strValues.Length == 0)
                    return "";
    
                if (valueLinkChar == null || valueLinkChar.Length == 0)
                    valueLinkChar = ",";
    
                string[] sArray 
                    = 
                    strValues.Split(valueLinkChar.ToCharArray());
    
                StringBuilder theResult = new StringBuilder();
                bool isFirst = true;
    
                foreach (string s in sArray)
                {
                    if (s == null || s.Length == 0)
                        continue;
    
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        theResult.Append(textLinkChar);
                    }
    
                    theResult.Append
                        (
                            GetShowName
                                (
                                    GetEmByString(s),
                                    showCode
                                )
                        );
                }
    
                return theResult.ToString();
            }
    
            #endregion 获得显示的名称的拼串 - GetShowNames
    
            #region GetEmByInt - 通过int(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            /// <summary>
            /// 通过int(value)值获得枚举EmUserRole,如果不存在,抛出异常
            /// </summary>
            /// <param name="theValue">枚举对应的int(value)值</param>
            /// <returns></returns>
            public static EmUserRole GetEmByInt(int theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (int)em)
                        return em;
                }
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> " 
                        + methodBaseValue.ReflectedType.FullName 
                        + " ~ " 
                        + methodBaseValue.ToString() 
                        + " Exception :==> "
                        + "theValue = " + theValue.ToString() + "没有找到对应的枚举值。"
                    );
            }
    
            #endregion GetEmByInt - 通过int(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            #region GetEmByLong - 通过long(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            /// <summary>
            /// 通过long(value)值获得枚举EmUserRole,如果不存在,抛出异常
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static EmUserRole GetEmByLong(long theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (long)em)
                        return em;
                }
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> " 
                        + methodBaseValue.ReflectedType.FullName 
                        + " ~ " 
                        + methodBaseValue.ToString() 
                        + " Exception :==> " 
                        + "theValue = " + theValue.ToString() + "没有找到对应的枚举值。"
                    );
            }
    
            #endregion GetEmByLong - 通过long(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            #region GetEmByString - 通过string(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            /// <summary>
            /// 通过string(value)值获得枚举EmUserRole,如果不存在,抛出异常
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static EmUserRole GetEmByString(string theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == ((int)em).ToString())
                        return em;
                }
    
                MethodBase methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> " 
                        + methodBaseValue.ReflectedType.FullName 
                        + " ~ " 
                        + methodBaseValue.ToString() 
                        + " Exception :==> " 
                        + "theValue = " + theValue + "没有找到对应的枚举值。"
                    );
    
            }
    
            #endregion GetEmByString - 通过string(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            #region GetEmByObj - 通过object(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            /// <summary>
            /// 通过object(value)值获得枚举EmUserRole,如果不存在,抛出异常
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static EmUserRole GetEmByObj(object theValue)
            {
                MethodBase methodBaseValue = null;
    
                if (theValue == null)
                {
                    methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> " 
                            + methodBaseValue.ReflectedType.FullName 
                            + " ~ " 
                            + methodBaseValue.ToString() 
                            + " Exception :==> " 
                            + "theValue为null,没有找到对应的枚举值。"
                        );
                }
    
                if (theValue is EmUserRole)
                    return (EmUserRole)theValue;
    
                string strValue = theValue.ToString();
    
                if (strValue.Length == 0)
                {
                    methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> " 
                            + methodBaseValue.ReflectedType.FullName 
                            + " ~ " 
                            + methodBaseValue.ToString() 
                            + " Exception :==> " 
                            + "theValue为空,没有找到对应的枚举值。"
                        );
                }
    
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (strValue == ((int)em).ToString())
                        return em;
                }
    
                methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> " 
                        + methodBaseValue.ReflectedType.FullName 
                        + " ~ " 
                        + methodBaseValue.ToString() 
                        + " Exception :==> " 
                        + "theValue = " + strValue.ToString() + "没有找到对应的枚举值。"
                    );
            }
    
            #endregion GetEmByObj - 通过object(value)值获得枚举EmUserRole,如果不存在,抛出异常
    
            #region GetDefaultEmByInt - 通过int(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            /// <summary>
            /// 通过int(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByInt(int theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (int)em)
                        return em;
                }
    
                return defaultEm;
            }
    
            #endregion GetDefaultEmByInt - 通过int(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            #region GetDefaultEmByLong - 通过long(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            /// <summary>
            /// 通过long(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByLong(long theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (long)em)
                        return em;
                }
    
                return defaultEm;
            }
    
            #endregion GetDefaultEmByLong - 通过long(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            #region GetDefaultEmByString - 通过string(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            /// <summary>
            /// 获得枚举
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByString(string theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == ((int)em).ToString())
                        return em;
                }
    
                return defaultEm;
            }
    
            #endregion GetDefaultEmByString - 通过string(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            #region GetDefaultEmByObj- 通过object(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            /// <summary>
            /// 通过object(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByObj(object theValue)
            {
                if (theValue == null)
                    return defaultEm;
    
                if (theValue is EmUserRole)
                    return (EmUserRole)theValue;
    
                string strValue = theValue.ToString();
    
                if (strValue.Length == 0)
                    return defaultEm;
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (strValue == ((int)em).ToString())
                        return em;
                }
    
                return defaultEm;
            }
    
            #endregion GetDefaultEmByObj- 通过object(value)值获得枚举EmUserRole,如果不存在,返回defaultEm对应的枚举值
    
            #region GetDefaultEmByInt - 通过int(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
            /// <summary>
            /// 通过int(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByInt(int theValue, EmUserRole defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (int)em)
                        return em;
                }
    
                return defaultValue;
            }
    
            #endregion GetDefaultEmByInt - 通过int(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
    
            #region GetDefaultEmByLong - 通过long(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
            /// <summary>
            /// 通过long(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByLong(long theValue, EmUserRole defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (long)em)
                        return em;
                }
    
                return defaultValue;
            }
    
            #endregion GetDefaultEmByLong - 通过long(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
    
            #region GetDefaultEmByString - 通过string(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
            /// <summary>
            /// 通过string(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByString(string theValue, EmUserRole defaultValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == ((int)em).ToString())
                        return em;
                }
    
                return defaultValue;
            }
    
            #endregion GetDefaultEmByString - 通过string(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
            #region GetDefaultEmByObj - 通过object(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
            /// <summary>
            /// 通过object(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByObj(object theValue, EmUserRole defaultValue)
            {
                if (theValue == null)
                    return defaultValue;
    
                string strValue = theValue.ToString();
    
                if (strValue.Length == 0)
                    return defaultValue;
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (strValue == ((int)em).ToString())
                        return em;
                }
    
                return defaultValue;
            }
    
            #endregion GetDefaultEmByObj - 通过object(value)值获得枚举EmUserRole,如果不存在,返回defaultValue对应的枚举值
    
            #region GetEmByText - 通过 theText(枚举文本) 获得 EmUserRole,如果不存在,抛出异常
    
            /// <summary>
            /// 通过 theText(枚举文本) 获得 EmUserRole,如果不存在,抛出异常
            /// </summary>
            /// <param name="theText"></param>
            /// <returns></returns>
            public static EmUserRole GetEmByText(string theText)
            {
                MethodBase methodBaseValue = null;
    
                if (theText == null)
                {
                    methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> " 
                            + methodBaseValue.ReflectedType.FullName 
                            + " ~ " 
                            + methodBaseValue.ToString() 
                            + " Exception :==> " 
                            + "theText为null,没有找到对应的枚举值。"
                        );
                }
    
                if (theText.Length == 0)
                {
                    methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception
                        (
                            "Method :==> " 
                            + methodBaseValue.ReflectedType.FullName 
                            + " ~ " 
                            + methodBaseValue.ToString() 
                            + " Exception :==> " 
                            + "theText为空,没有找到对应的枚举值。"
                        );
                }
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theText == GetShowName(em))
                        return em;
                }
    
                methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception
                    (
                        "Method :==> " 
                        + methodBaseValue.ReflectedType.FullName 
                        + " ~ " 
                        + methodBaseValue.ToString() 
                        + " Exception :==> " 
                        + "theText = " 
                        + theText.ToString() 
                        + "没有找到对应的枚举值。"
                    );
            }
    
            #endregion GetEmByText - 通过 theText(枚举文本) 获得 EmUserRole,如果不存在,抛出异常
    
            #region GetDefaultEmByText - 通过 theText(枚举文本) 获得 EmUserRole,如果不存在,返回defaultValue
    
            /// <summary>
            /// 通过 theText(枚举文本) 获得 EmUserRole,如果不存在,返回defaultValue
            /// </summary>
            /// <param name="theText"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByText(string theText, EmUserRole defaultValue)
            {
                if (theText == null)
                    return defaultValue;
    
                if (theText.Length == 0)
                    return defaultValue;
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theText == (em).ToString())
                        return em;
                }
    
                return defaultValue;
            }
    
            #endregion GetDefaultEmByText - 通过 theText(枚举文本) 获得 EmUserRole,如果不存在,返回defaultValue
    
            #region GetEmByAllObj - 通过 object(枚举/value值/文本值) 获得 EmUserRole,如果不存在,抛出异常
    
            /// <summary>
            /// 通过 object(枚举/value值/文本值) 获得 EmUserRole,如果不存在,抛出异常
            /// </summary>
            /// <param name="theValue"></param> 
            /// <returns></returns>
            public static EmUserRole GetEmByAllObj(object theValue)
            {
                MethodBase methodBaseValue = null;
    
                if (theValue == null)
                {
                    methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception("Method :==> " + methodBaseValue.ReflectedType.FullName + " ~ " + methodBaseValue.ToString() + " Exception :==> " + "theValue为null,没有找到对应的枚举值。");
                }
    
                if (theValue is EmUserRole)
                    return (EmUserRole)theValue;
    
                string strValue = theValue.ToString();
    
                if (strValue.Length == 0)
                {
                    methodBaseValue = MethodBase.GetCurrentMethod();
    
                    throw new Exception("Method :==> " + methodBaseValue.ReflectedType.FullName + " ~ " + methodBaseValue.ToString() + " Exception :==> " + "theValue为空,没有找到对应的枚举值。");
                }
    
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (strValue == ((int)em).ToString() || strValue == em.ToString())
                        return em;
                }
    
                methodBaseValue = MethodBase.GetCurrentMethod();
    
                throw new Exception("Method :==> " + methodBaseValue.ReflectedType.FullName + " ~ " + methodBaseValue.ToString() + " Exception :==> " + "theValue = " + strValue.ToString() + "没有找到对应的枚举值。");
            
            }
    
            #endregion GetEmByAllObj - 通过 object(枚举/value值/文本值) 获得 EmUserRole,如果不存在,抛出异常
    
    
            #region GetDefaultEmByAllObj - 通过 object(枚举/value值/文本值) 获得 EmUserRole,如果不存在,返回defaultValue
    
            /// <summary>
            /// 通过 object(枚举/value值/文本值) 获得 EmUserRole,如果不存在,返回defaultValue
            /// </summary>
            /// <param name="theValue"></param>
            /// <param name="defaultValue"></param>
            /// <returns></returns>
            public static EmUserRole GetDefaultEmByAllObj(object theValue, EmUserRole defaultValue)
            {
                if (theValue == null)
                    return defaultValue;
    
                string strValue = theValue.ToString();
    
                if (strValue.Length == 0)
                    return defaultValue;
    
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (strValue == ((int)em).ToString() || strValue == em.ToString())
                        return em;
                }
    
                return defaultValue;
            }
    
            #endregion GetDefaultEmByAllObj - 通过 object(枚举/value值/文本值) 获得 EmUserRole,如果不存在,返回defaultValue
    
    
            #region IsEmByInt - 通过int(value)值判断是否枚举值
    
            /// <summary>
            /// 通过int(value)值判断是否枚举值
            /// </summary>
            /// <param name="theValue">枚举对应的int(value)值</param>
            /// <returns></returns>
            public static bool IsEmByInt(int theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (int)em)
                        return true;
                }
    
                return false;
            }
    
            #endregion IsEmByInt - 通过int(value)值判断是否枚举值
    
            #region IsEmByLong - 通过long(value)值判断是否枚举值
    
            /// <summary>
            /// 通过long(value)值判断是否枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static bool IsEmByLong(long theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == (long)em)
                        return true;
                }
    
                return false;
            }
    
            #endregion IsEmByLong - 通过long(value)值判断是否枚举值
    
            #region IsEmByString - 通过string(value)值判断是否枚举值
    
            /// <summary>
            /// 通过string(value)值判断是否枚举值
            /// </summary>
            /// <param name="theValue"></param>
            /// <returns></returns>
            public static bool IsEmByString(string theValue)
            {
                EmUserRole[] emA = EmArray;
    
                foreach (EmUserRole em in emA)
                {
                    if (theValue == ((int)em).ToString())
                        return true;
                }
    
    
                return false;
    
            }
    
            #endregion IsEmByString - 通过string(value)值值判断是否枚举值
    
        }
    
    
    }
    
    
    

上一条:

下一条:


 
 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)