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

📄 fixedclientsetting.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace Imps.Client.Core
{
    using Imps.Client;
    using Imps.Client.Resource;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Reflection;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Xml;

    public class FixedClientSetting : IDictionary<string, string>, ICollection<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>, IEnumerable
    {
        private const string _cfgFile = "Client.config";
        private static XmlDocument _cfgXmlDoc = new XmlDocument();
        private Dictionary<string, string> _dic = new Dictionary<string, string>();
        private bool _duringDebug;
        private static Imps.Client.Core.FixedClientSetting _instance = new Imps.Client.Core.FixedClientSetting();
        private const string _noUpdateAbleCfgFile = "ClientFixed.config";
        private const string _ourNamespace = "Imps.Client.Core.Configuration";
        private const string _rootNodeName = "AppSettings";
        private Imps.Client.ShareContentType? _shareContentType;

        private FixedClientSetting()
        {
            this.InitUpdateAbleCfg();
            this.InitNoUpdateAbleCfg();
        }

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

        public void Add(string key, string value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

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

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

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

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

        private XmlDocument GetCfgXml()
        {
            string path = Path.Combine(ImpsPathInfo.StartupPath, "Client.config");
            XmlDocument xmlCfg = new XmlDocument();
            if (!File.Exists(path))
            {
                xmlCfg.Load(this.GetDefaultAppSetingXml());
                try
                {
                    this.SaveAppSetting(xmlCfg);
                }
                catch
                {
                }
                return xmlCfg;
            }
            try
            {
                xmlCfg.Load(path);
            }
            catch
            {
                xmlCfg.Load(this.GetDefaultAppSetingXml());
                this.SaveAppSetting(xmlCfg);
            }
            return xmlCfg;
        }

        private Stream GetDefaultAppSetingXml()
        {
            return Assembly.GetExecutingAssembly().GetManifestResourceStream("Imps.Client.Core.Configuration.defaultAppSetting.xml");
        }

        public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
        {
            return this._dic.GetEnumerator();
        }

        private void InitNoUpdateAbleCfg()
        {
            string path = Path.Combine(ImpsPathInfo.StartupPath, "ClientFixed.config");
            XmlDocument document = new XmlDocument();
            if (File.Exists(path))
            {
                try
                {
                    document.Load(path);
                    foreach (XmlNode node2 in document.DocumentElement.SelectSingleNode("AppSettings").ChildNodes)
                    {
                        if (!(node2 is XmlComment) && !this._dic.ContainsKey(node2.Attributes["key"].Value))
                        {
                            this._dic.Add(node2.Attributes["key"].Value, node2.Attributes["value"].Value);
                        }
                    }
                }
                catch
                {
                }
            }
        }

        private void InitUpdateAbleCfg()
        {
            if (!this._dic.ContainsKey("Version"))
            {
                System.Version version = Assembly.GetEntryAssembly().GetName().Version;
                string format = "{0}.{1}.{2}";
                format = string.Format(format, version.Major.ToString(), version.Minor.ToString(), version.Build.ToString().PadLeft(4, '0'));
                this._dic.Add("Version", format);
            }
            foreach (object obj2 in Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false))
            {
                foreach (string text3 in ((AssemblyConfigurationAttribute) obj2).Configuration.Split(new char[] { ';' }))
                {
                    string[] textArray2 = text3.Split(new char[] { '=' });
                    if (((textArray2 != null) && (textArray2.Length == 2)) && !this._dic.ContainsKey(textArray2[0]))
                    {
                        this._dic.Add(textArray2[0], textArray2[1]);
                    }
                }
            }
            XmlDocument cfgXml = this.GetCfgXml();
            try
            {
                foreach (XmlNode node2 in cfgXml.DocumentElement.SelectSingleNode("AppSettings").ChildNodes)
                {
                    if (!(node2 is XmlComment) && !this._dic.ContainsKey(node2.Attributes["key"].Value))
                    {
                        this._dic.Add(node2.Attributes["key"].Value, node2.Attributes["value"].Value);
                    }
                }
            }
            catch
            {
            }
        }

        public bool Remove(KeyValuePair<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.");
        }

        private void SaveAppSetting(XmlDocument xmlCfg)
        {
            try
            {
                using (XmlTextWriter w = new XmlTextWriter("Client.config", Encoding.UTF8))
                {
                    xmlCfg.Save(w);
                }
            }
            catch
            {
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this._dic.GetEnumerator();
        }

        public bool TryGetValue(string key, out string value)
        {
            return this._dic.TryGetValue(key, ref value);
        }

        public string AppEnglishName
        {
            get
            {
                return AppDictionary.ShortEnglishName;
            }
        }

        public string AppName
        {
            get
            {
                return AppDictionary.ShortLocalName;
            }
        }

        public string Branch
        {
            get
            {
                string text = string.Empty;
                if (this._dic.ContainsKey("Branch"))
                {
                    text = this._dic.get_Item("Branch");
                }
                if (text.Length <= 0)
                {
                    return "Default";
                }
                return text;
            }
        }

        public DateTime BuildDate
        {
            get
            {
                try
                {
                    DateTime now = DateTime.Now;
                    DateTime.TryParse(this._dic.get_Item("BuildDate"), ref now);
                    return now;
                }
                catch
                {
                    return DateTime.Now;
                }
            }
        }

        public string ChangePasswordNo
        {
            get
            {
                string text = string.Empty;
                if (this._dic.ContainsKey("ChangePasswordNo"))
                {
                    text = this._dic.get_Item("ChangePasswordNo");
                }
                if (text.Length <= 0)
                {
                    return "12520050";
                }
                return text;
            }
        }

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

        public string Debug_LiveUpdateSwitch
        {
            get
            {
                string text = "Default";
                this.TryGetValue("Debug_LiveUpdateSwitch", out text);
                return text;
            }
        }

        public string Debug_LiveupdateUrl
        {
            get
            {
                string text = string.Empty;
                if (this._dic.ContainsKey("Debug_LiveUpdateUrl"))
                {
                    text = this._dic.get_Item("Debug_LiveUpdateUrl");
                }
                return text;
            }
        }

        public string Debug_MobileEmailCheckInterval
        {
            get
            {
                string text;
                this.TryGetValue("Debug_MobileEmailCheckInterval", out text);
                return text;
            }
        }

        public string Debug_STUNServerUrl
        {
            get
            {
                string text = string.Empty;
                if (this._dic.ContainsKey("Debug_STUNServerUrl"))
                {
                    text = this._dic.get_Item("Debug_STUNServerUrl");
                }
                return text;
            }
        }

        public bool Debug_TestHttpConnection
        {
            get
            {
                string text;
                bool flag;
                this.TryGetValue("Debug_TestHttpConnection", out text);
                if (bool.TryParse(text, ref flag))
                {
                    return flag;
                }
                return false;
            }
        }

        [ConfigCategory(ConfigCategory.LocalFixed)]
        public string DefaultLanguage
        {
            get
            {
                string text = "zh-CN";
                if (this._dic.ContainsKey("DefaultLanguage"))

⌨️ 快捷键说明

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