settingscollection.cs

来自「PowUpload的C#源文件,用来做大文件上传的项目」· CS 代码 · 共 59 行

CS
59
字号
namespace ElementIT.PowUpload
{
    using System;
    using System.Collections.Specialized;
    using System.Reflection;

    public class SettingsCollection : NameObjectCollectionBase
    {
        private bool _isCommonSettingsCol;
        internal DateTime _timeCreated = DateTime.MinValue;

        internal SettingsCollection(bool isCommonSettingsCol)
        {
            this._timeCreated = DateTime.Now;
            this._isCommonSettingsCol = isCommonSettingsCol;
        }

        internal bool HasKey(string Name)
        {
            for (int i = 0; i < base.Keys.Count; i++)
            {
                if (string.Compare(base.Keys[i], Name, true) == 0)
                {
                    return true;
                }
            }
            return false;
        }

        public object this[string Name]
        {
            get
            {
                if (this.HasKey(Name))
                {
                    return base.BaseGet(Name);
                }
                if (this._isCommonSettingsCol)
                {
                    return null;
                }
                return Settings.CommonSettings[Name];
            }
            set
            {
                if (this.HasKey(Name))
                {
                    base.BaseSet(Name, value);
                }
                else
                {
                    base.BaseAdd(Name, value);
                }
            }
        }
    }
}

⌨️ 快捷键说明

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