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

📄 networksetting.cs

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

    public class NetworkSetting : PropertyDictionary
    {
        private bool _changed;
        private static Imps.Client.Core.NetworkSetting _instance = null;
        private static object _lock = new object();
        private Dictionary<ProxyType, NetworkProxy> _proxies = new Dictionary<ProxyType, NetworkProxy>();
        private bool _saveLog;
        private volatile bool _suspend;
        private bool _useHttpProxy = true;
        private bool _useIeProxy = true;
        private bool _useSocksProxy;
        private bool _useTcp = true;

        public event EventHandler Changed;

        internal NetworkSetting()
        {
            this._proxies.Add(ProxyType.HttpProxy, new NetworkProxy(this));
            this._proxies.Add(ProxyType.SocksProxy, new NetworkProxy(this));
            _instance = this;
        }

        public void BeginUpdate()
        {
            this._suspend = true;
        }

        public void EndUpdate()
        {
            this._suspend = false;
            if (this._changed)
            {
                this.FireChangeEvent();
            }
        }

        internal void FireChangeEvent()
        {
            if ((!this._suspend && this._changed) && (this.Changed != null))
            {
                this.Changed(this, EventArgs.Empty);
            }
        }

        public override bool HasProposedProperty()
        {
            return this._changed;
        }

        public void LoadXml(XmlNode xmlNode)
        {
            bool flag = false;
            XmlNode node = xmlNode.SelectSingleNode("SaveLog");
            if (node != null)
            {
                bool.TryParse(node.InnerText, ref flag);
            }
            XmlNode node2 = xmlNode.SelectSingleNode("Use");
            if (node2 != null)
            {
                string[] textArray = node2.InnerText.Split(new char[] { ',' });
                for (int i = 0; i < textArray.Length; i++)
                {
                    switch (i)
                    {
                        case 0:
                            bool.TryParse(textArray[i], ref this._useTcp);
                            break;

                        case 1:
                            bool.TryParse(textArray[i], ref this._useSocksProxy);
                            break;

                        case 2:
                            bool.TryParse(textArray[i], ref this._useHttpProxy);
                            break;

                        case 3:
                            bool.TryParse(textArray[i], ref this._useIeProxy);
                            break;
                    }
                }
            }
            XmlNodeList list = xmlNode.SelectNodes("NetworkProxy");
            if (list != null)
            {
                foreach (XmlNode node3 in list)
                {
                    NetworkProxy httpProxy;
                    if (node3.Attributes["ProxyType"] == null)
                    {
                        continue;
                    }
                    int num2 = 0;
                    int.TryParse(node3.Attributes["ProxyType"].Value, ref num2);
                    if (num2 == 1)
                    {
                        httpProxy = this.HttpProxy;
                    }
                    else
                    {
                        if (num2 != 5)
                        {
                            break;
                        }
                        httpProxy = this.SocksProxy;
                    }
                    foreach (XmlNode node4 in node3.ChildNodes)
                    {
                        switch (node4.Name)
                        {
                            case "ServerUri":
                            {
                                httpProxy.ServerUri = node4.InnerText;
                                continue;
                            }
                            case "ServerPort":
                            {
                                int num3 = 0;
                                int.TryParse(node4.InnerText, ref num3);
                                httpProxy.ServerPort = num3;
                                continue;
                            }
                            case "UserName":
                            {
                                httpProxy.UserName = node4.InnerText;
                                continue;
                            }
                            case "Password":
                                break;

                            default:
                            {
                                continue;
                            }
                        }
                        httpProxy.Password = node4.InnerText;
                    }
                }
            }
        }

        public string ToWndXml()
        {
            string text = "<NetworkSetting>";
            return (((((text + string.Format("<SaveLog></SaveLog>", this.SaveLog.ToString())) + string.Format("<Use>{0}</Use>", this.UseDirect.ToString() + "," + this.UseSocksProxy.ToString() + "," + this.UseHttpProxy.ToString() + "," + this.UseIeProxy.ToString()) + string.Format("<NetworkProxy ProxyType=\"{0}\">", 1)) + this.HttpProxy.ToString() + "</NetworkProxy>") + string.Format("<NetworkProxy ProxyType=\"{0}\">", 5) + this.SocksProxy.ToString()) + "</NetworkProxy>" + "</NetworkSetting>");
        }

        public NetworkProxy HttpProxy
        {
            get
            {
                return this._proxies.get_Item(ProxyType.HttpProxy);
            }
        }

        public static Imps.Client.Core.NetworkSetting Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (_lock)
                    {
                        if (_instance == null)
                        {
                            _instance = new Imps.Client.Core.NetworkSetting();
                        }
                    }
                }
                return _instance;
            }
        }

        public bool SaveLog
        {
            get
            {
                return this._saveLog;
            }
            set
            {
                this._saveLog = value;
                this._changed = true;
            }
        }

        public NetworkProxy SocksProxy
        {
            get
            {
                return this._proxies.get_Item(ProxyType.SocksProxy);
            }
        }

        public bool UseDirect
        {
            get
            {
                return true;
            }
            set
            {
                this._useTcp = value;
                this._changed = true;
            }
        }

        public bool UseHttpProxy
        {
            get
            {
                return true;
            }
            set
            {
                this._useHttpProxy = value;
                this._changed = true;
            }
        }

        public bool UseIeProxy
        {
            get
            {
                return this._useIeProxy;
            }
            set
            {
                this._useIeProxy = value;
                this._changed = true;
            }
        }

        public bool UseSocksProxy
        {
            get
            {
                return false;
            }
            set
            {
                this._useSocksProxy = value;
                this._changed = true;
            }
        }
    }
}

⌨️ 快捷键说明

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