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

📄 settings.cs

📁 PowUpload的C#源文件,用来做大文件上传的项目
💻 CS
字号:
namespace ElementIT.PowUpload
{
    using System;
    using System.Runtime.InteropServices;

    public class Settings
    {
        private static long _HTTPRuntime_MaxRequestLength = -1;
        public static SettingsCollection CommonSettings = new SettingsCollection(true);
        public static SingleRequestSettings SingleSettings = new SingleRequestSettings();

        static Settings()
        {
            InitCommonSettings();
        }

        internal Settings()
        {
        }

        internal static object GetValue(string id, string name)
        {
            if (((id != null) && (SingleRequestSettings._personalSettings[id] != null)) && ((SettingsCollection) SingleRequestSettings._personalSettings[id]).HasKey(name))
            {
                return ((SettingsCollection) SingleRequestSettings._personalSettings[id])[name];
            }
            return CommonSettings[name];
        }

        internal static void InitCommonSettings()
        {
            try
            {
                _HTTPRuntime_MaxRequestLength = long.Parse(Common.GetWebConfigValue("system.web/httpRuntime", "maxRequestLength", false, "nothing").ToString());
                if (Environment.Version.Major >= 2)
                {
                    _HTTPRuntime_MaxRequestLength *= 0x400;
                }
            }
            catch
            {
                _HTTPRuntime_MaxRequestLength = long.Parse("4194304");
            }
            CommonSettings["processPages"] = Common.GetConfigValue("settings", "processPages", false, "*.aspx").ToString();
            CommonSettings["ignorePages"] = Common.GetConfigValue("settings", "ignorePages", false, "").ToString();
            CommonSettings["writeDebugLogs"] = Common.StrToBln(Common.GetConfigValue("settings", "writeDebugLogs", false, "false").ToString());
            object obj3 = Common.GetConfigValue("settings", "bandwidthLimit", false, "-1");
            try
            {
                CommonSettings["bandwidthLimit"] = int.Parse(obj3.ToString());
            }
            catch
            {
                CommonSettings["bandwidthLimit"] = int.Parse("-1");
            }
            CommonSettings["uploadIDQueryField"] = Common.GetConfigValue("settings", "uploadIDQueryField", false, "UploadID").ToString();
            CommonSettings["throwErrorsImmediately"] = Common.StrToBln(Common.GetConfigValue("settings", "throwErrorsImmediately", false, "true").ToString());
            CommonSettings["logExceptions"] = Common.StrToBln(Common.GetConfigValue("settings", "logExceptions", false, "false").ToString());
            object obj4 = Common.GetConfigValue("settings", "minRequestLengthProcess", false, "-1");
            try
            {
                CommonSettings["minRequestLengthProcess"] = long.Parse(obj4.ToString());
            }
            catch
            {
                CommonSettings["minRequestLengthProcess"] = long.Parse("-1");
            }
            CommonSettings["ignoreHttpRuntimeMaxRequestLength"] = Common.StrToBln(Common.GetConfigValue("settings", "ignoreHttpRuntimeMaxRequestLength", false, "true").ToString());
            CommonSettings["passForm"] = Common.StrToBln(Common.GetConfigValue("settings", "passForm", false, "true").ToString());
            object obj5 = Common.GetConfigValue("settings", "maxRequestLength", false, "-1");
            try
            {
                CommonSettings["maxRequestLength"] = long.Parse(obj5.ToString());
            }
            catch
            {
                CommonSettings["maxRequestLength"] = long.Parse("-1");
            }
            object obj6 = Common.GetConfigValue("settings", "maxRequestLengthToCloseConnection", false, "-1");
            try
            {
                CommonSettings["maxRequestLengthToCloseConnection"] = long.Parse(obj6.ToString());
            }
            catch
            {
                CommonSettings["maxRequestLengthToCloseConnection"] = long.Parse("-1");
            }
            CommonSettings["tempPath"] = Common.GetConfigValue("settings", "tempPath", false, @"C:\Temp\").ToString();
            object obj7 = Common.GetConfigValue("settings", "bufferSize", false, "16384");
            try
            {
                CommonSettings["bufferSize"] = int.Parse(obj7.ToString());
            }
            catch
            {
                CommonSettings["bufferSize"] = int.Parse("16384");
            }
        }

        public static long HTTPRuntime_MaxRequestLength
        {
            get
            {
                return _HTTPRuntime_MaxRequestLength;
            }
        }

        [StructLayout(LayoutKind.Sequential, Size=1)]
        public struct SettingsParams
        {
            public const string UploadIDQueryField = "uploadIDQueryField";
            public const string ProcessPages = "processPages";
            public const string MaxRequestLength = "maxRequestLength";
            public const string IgnorePages = "ignorePages";
            public const string ThrowErrorsImmediately = "throwErrorsImmediately";
            public const string LogExceptions = "logExceptions";
            public const string MinRequestLengthProcess = "minRequestLengthProcess";
            public const string TempPath = "tempPath";
            public const string IgnoreHttpRuntimeMaxRequestLength = "ignoreHttpRuntimeMaxRequestLength";
            public const string UploadHandleObject = "uploadHandleObject";
            public const string MaxRequestLengthToCloseConnection = "maxRequestLengthToCloseConnection";
            public const string BandwidthLimit = "bandwidthLimit";
            public const string PassForm = "passForm";
            internal const string WriteDebugLogs = "writeDebugLogs";
            internal const string BufferSize = "bufferSize";
        }
    }
}

⌨️ 快捷键说明

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