⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 impsenums.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Resource
{
    using Imps.Client;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Runtime.InteropServices;
    using System.Xml;

    public class IMPSEnums : IDictionary<string, Dictionary<string, string>>, ICollection<KeyValuePair<string, Dictionary<string, string>>>, IEnumerable<KeyValuePair<string, Dictionary<string, string>>>, IEnumerable
    {
        private static Dictionary<string, Dictionary<string, string>> _EnumDic = new Dictionary<string, Dictionary<string, string>>();
        private static IMPSEnums _instance = new IMPSEnums();
        private const string NN_RootNode = "Enums";
        private const string resXml = "Enum.IMPSEnumDictionary.xml";

        private IMPSEnums()
        {
            this.Init();
        }

        public void Add(KeyValuePair<string, Dictionary<string, string>> item)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public void Add(string key, Dictionary<string, string> value)
        {
            _EnumDic.Add(key, value);
        }

        public void Clear()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool Contains(KeyValuePair<string, Dictionary<string, string>> item)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool ContainsKey(string key)
        {
            return _EnumDic.ContainsKey(key);
        }

        public void CopyTo(KeyValuePair<string, Dictionary<string, string>>[] array, int arrayIndex)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public static T GetEnumByDescription<T>(string p)
        {
            T local = default(T);
            Type enumType = typeof(T);
            if (enumType.IsEnum)
            {
                T[] values = (T[]) Enum.GetValues(enumType);
                for (int i = 0; i < values.Length; i++)
                {
                    if (_EnumDic.get_Item(enumType.Name).get_Item(values[i].ToString()) == p)
                    {
                        return values[i];
                    }
                }
            }
            return local;
        }

        public static string GetEnumDescription<Enum>(Enum value) where Enum: struct
        {
            return Instance[value.GetType().Name].get_Item(value.ToString());
        }

        public static List<EnumDescription<T>> GetEnumDescriptionList<T>() where T: struct
        {
            List<EnumDescription<T>> list = new List<EnumDescription<T>>();
            Type enumType = typeof(T);
            if (enumType.IsEnum)
            {
                T[] values = (T[]) Enum.GetValues(enumType);
                for (int i = 0; i < values.Length; i++)
                {
                    list.Add(new EnumDescription<T>(values[i], Instance[enumType.Name].get_Item(values[i].ToString())));
                }
            }
            return list;
        }

        public IEnumerator<KeyValuePair<string, Dictionary<string, string>>> GetEnumerator()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private void Init()
        {
            try
            {
                XmlDocument document = new XmlDocument();
                document.Load(ImpsResources.GetResourceStream("Enum.IMPSEnumDictionary.xml"));
                foreach (XmlNode node2 in document.DocumentElement.SelectSingleNode("Enums").ChildNodes)
                {
                    Dictionary<string, string> dictionary = new Dictionary<string, string>();
                    foreach (XmlNode node3 in node2.ChildNodes)
                    {
                        dictionary.Add(node3.Name, node3.InnerText);
                    }
                    _EnumDic.Add(node2.Name, dictionary);
                }
            }
            catch
            {
            }
        }

        public bool Remove(KeyValuePair<string, Dictionary<string, string>> item)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool Remove(string key)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public bool TryGetValue(string key, out Dictionary<string, string> value)
        {
            return _EnumDic.TryGetValue(key, ref value);
        }

        public int Count
        {
            get
            {
                return _EnumDic.get_Count();
            }
        }

        public static IMPSEnums Instance
        {
            get
            {
                return _instance;
            }
        }

        public bool IsReadOnly
        {
            get
            {
                return true;
            }
        }

        public Dictionary<string, string> this[string key]
        {
            get
            {
                if (this.ContainsKey(key))
                {
                    return _EnumDic.get_Item(key);
                }
                return null;
            }
            set
            {
                if (this.ContainsKey(key))
                {
                    _EnumDic.set_Item(key, value);
                }
            }
        }

        public ICollection<string> Keys
        {
            get
            {
                return _EnumDic.get_Keys();
            }
        }

        public ICollection<Dictionary<string, string>> Values
        {
            get
            {
                return _EnumDic.get_Values();
            }
        }

        public class EnumDescription<T>
        {
            private string _description;
            private T _value;

            internal EnumDescription(T value, string description)
            {
                this._value = value;
                this._description = description;
            }

            public string Description
            {
                get
                {
                    return this._description;
                }
                internal set
                {
                    this._description = value;
                }
            }

            public T Value
            {
                get
                {
                    return this._value;
                }
                internal set
                {
                    this._value = value;
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -