移动系统liao
2024-06-17 e98303dc5e2ce122c8788189183c7600b11a2f5c
CoreCms.Net.Utility/Extensions/ObjectExtensions.cs
@@ -1,9 +1,9 @@
/***********************************************************************
 *            Project: CoreCms.Net                                     *
 *                Web: https://CoreCms.Net                             *
 *        ProjectName: 核心内容管理系统                                *
 *             Author: 大灰灰                                          *
 *              Email: JianWeie@163.com                                *
 *            Project: baifenBinfa.Net                                     *
 *                Web: https://baifenBinfa.com                             *
 *        ProjectName: 百分兵法管理系统                               *
 *             Author:                                        *
 *              Email:                               *
 *           Versions: 1.0                                             *
 *         CreateTime: 2020-02-01 17:48:52
 *          NameSpace: CoreCms.Net.Framework.Utility.Extensions
@@ -14,6 +14,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace CoreCms.Net.Utility.Extensions
@@ -174,8 +175,18 @@
            return thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out result) ? result : result;
        }
        /// <summary>
        /// 获取枚举的标注的值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetDescription(this Enum value)
        {
            var field = value.GetType().GetField(value.ToString());
            var attributes = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), false);
            return attributes.Length > 0 ? attributes[0].Description : value.ToString();
        }
    }
}