KingNET.PageLib/Utils/EnumBase.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using DMSFrame;
using System.Threading;

namespace KingNET.PageLib.Utils
{
    public static class EnumBaseExtentions
    {
        public static string GetDescription(this EnumBase enumValue, int value)
        {
            return EnumBase.GetDescription(enumValue.GetType(), value);
        }
    }

    public class EnumBaseDictionary
    {
        public string DictionaryText { get; set; }
        public int DictionaryValue { get; set; }
    }
    public abstract class EnumBase
    {
        public static List<EnumBaseDictionary> GetEnumBaseDictionary(Type type)
        {
            List<EnumBaseDictionary> result = new List<EnumBaseDictionary>();
            Dictionary<int, string> keyValue = GetDictionary(type);
            foreach (KeyValuePair<int, string> item in keyValue)
            {
                result.Add(new EnumBaseDictionary() { DictionaryText = item.Value, DictionaryValue = item.Key });
            }
            return result;
        }
        /// <summary>
        /// 获取所有字段值和说明信息的列表
        /// </summary>
        public static Dictionary<int, string> GetDictionary(Type type)
        {
            Dictionary<int, string> dictionary = new Dictionary<int, string>();

            FieldInfo[] fields = type.GetFields();

            foreach (FieldInfo field in fields)
            {
                dictionary.Add(TryParse.StrToInt(field.GetValue(type).ToString()), GetDescription(field));
            }

            return dictionary;
        }
        /// <summary>
        /// 获取所有字段值和说明信息的列表
        /// </summary>
        public static Dictionary<string, string> GetDictionaryString(Type type)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            FieldInfo[] fields = type.GetFields();

后面还有 199 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。