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

📄 configuration.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace NCindy.Util
{
    using System;
    using System.Collections.Specialized;
    using System.Configuration;

    public static class Configuration
    {
        public const int DEFAULT_BUFFER_SIZE = 0x400;
        private static readonly NameValueCollection properties;

        static Configuration()
        {
            try
            {
                properties = new NameValueCollection();
                ConfigurationSectionGroup sectionGroup = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).GetSectionGroup("NCindy");
                if (sectionGroup != null)
                {
                    foreach (ConfigurationSection section in sectionGroup.Sections)
                    {
                        if (section is NCindyConfigurationSection)
                        {
                            foreach (NCindyConfigurationElement element in ((NCindyConfigurationSection) section).NCindy)
                            {
                                properties.Add(section.SectionInformation.Name + "." + element.Key, element.Value);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }

        public static string Get(string key)
        {
            if (properties == null)
            {
                return null;
            }
            return properties.Get(key);
        }

        public static string Get(string key, string defaultValue)
        {
            string text = Get(key);
            if (text != null)
            {
                return text;
            }
            return defaultValue;
        }

        public static bool GetBoolean(string key, bool defaultValue)
        {
            string text = Get(key);
            if (text != null)
            {
                try
                {
                    return bool.Parse(text);
                }
                catch (FormatException)
                {
                }
            }
            return defaultValue;
        }

        public static int GetInt(string key, int defaultValue)
        {
            string s = Get(key);
            if (s != null)
            {
                try
                {
                    return int.Parse(s);
                }
                catch (FormatException)
                {
                }
            }
            return defaultValue;
        }

        public static int AcceptorBacklog
        {
            get
            {
                return GetInt("Acceptor.Backlog", 100);
            }
        }

        public static string DefaultBufferPoolClass
        {
            get
            {
                return Get("Buffer.DefaultBufferPoolClass", "NCindy.Buffer.DefaultBufferPool");
            }
        }

        public static string DefaultDispatcherClass
        {
            get
            {
                return Get("Dispatcher.DefaultDispatcherClass", "DefaultDispatcher");
            }
        }

        public static string DefaultPipeSessionClass
        {
            get
            {
                return Get("Session.DefaultPipeSessionClass", "PipeSession");
            }
        }

        public static string DefaultTcpAcceptorClass
        {
            get
            {
                return Get("Acceptor.DefaultTcpAcceptorClass", "AsyncSocketSessionAcceptor");
            }
        }

        public static string DefaultTcpSessionClass
        {
            get
            {
                return Get("Session.DefaultTcpSessionClass", "AsyncSocketSession");
            }
        }

        public static string DefaultUdpSessionClass
        {
            get
            {
                return Get("Session.DefaultUdpSessionClass", "AsyncSocketSession");
            }
        }

        public static bool DisableInnerException
        {
            get
            {
                return GetBoolean("Global.DisableInnerException", false);
            }
        }

        public static int DispatcherCapacity
        {
            get
            {
                return GetInt("Dispatcher.Capacity", 0x3e8);
            }
        }

        public static int DispatcherConcurrent
        {
            get
            {
                return GetInt("Dispatcher.Concurrent", 1);
            }
        }

        public static int DispatcherKeepAliveTime
        {
            get
            {
                return GetInt("Dispatcher.KeepAliveTime", 0x1388);
            }
        }

        public static string LoggingLevel
        {
            get
            {
                return Get("Global.LoggingLevel", "Error");
            }
        }

        public static int MaxBufferPoolSize
        {
            get
            {
                return GetInt("Buffer.MaxBufferPoolSize", 0x400);
            }
        }

        public static int ReadPacketSize
        {
            get
            {
                return GetInt("Session.ReadPacketSize", 0x2000);
            }
        }

        public static int ReceiveBufferSize
        {
            get
            {
                return GetInt("Session.ReceiveBufferSize", -1);
            }
        }

        public static bool ReuseAcceptorAddress
        {
            get
            {
                return GetBoolean("Acceptor.ReuseAddress", false);
            }
        }

        public static bool ReuseSessionAddress
        {
            get
            {
                return GetBoolean("Session.ReuseAddress", false);
            }
        }

        public static int SendBufferSize
        {
            get
            {
                return GetInt("Session.SendBufferSize", -1);
            }
        }

        public static int SessionTimeout
        {
            get
            {
                return GetInt("Session.Timeout", 0);
            }
        }

        public static int SoLinger
        {
            get
            {
                return GetInt("Session.SoLinger", -1);
            }
        }

        public static bool TcpNoDelay
        {
            get
            {
                return GetBoolean("Session.TcpNoDelay", true);
            }
        }

        public static bool UseLinkedBuffer
        {
            get
            {
                return false;
            }
        }

        public static int WritePacketSize
        {
            get
            {
                return GetInt("Session.WritePacketSize", 0x100000);
            }
        }
    }
}

⌨️ 快捷键说明

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