Пример #1
0
        public INI_Setting(string name, string text, string desc, int position, string defaultValue,
                           string iniFilepath, string iniSection, string iniKey) : base(name, text, desc, defaultValue, position)
        {
            _iniFilepath = INIT.getpath(iniFilepath);

            _iniKey     = iniKey;
            _iniSection = iniSection;
            if (!string.IsNullOrEmpty(_iniFilepath))
            {
                IniManager _iniManager = new IniManager(_iniFilepath);

                if (!_iniSection.Equals("[NULL]"))
                {
                    if (!_iniManager.isKeyExist(_iniKey) || !_iniManager.isSectionExist(_iniSection))
                    {
                        if (!_iniKey.Contains(','))
                        {
                            throw new INIDataNotFoundException(_iniSection, _iniKey, _iniFilepath);
                        }
                        else
                        {
                            List <string> substrings = iniKey.Split(',').ToList <string>();
                            foreach (string s in substrings)
                            {
                                if (!_iniManager.isKeyExist(s))
                                {
                                    throw new INIDataNotFoundException(_iniSection, _iniKey, _iniFilepath);
                                }
                            }
                        }
                    }
                }
                _currentValue = "";
                _currentValue = _iniManager.getValueByKey(iniKey, iniSection);
            }
        }