예제 #1
0
        private bool Load(CINI ini, string section)
        {
            if (ini != null)
            {
                //load the section contain only if the
                if (_settings.ContainsKey(section))
                {
                    _settings[section] = new DictionaryFx <string, string>();

                    string[] entries = ini.GetEntryNames(section);
                    if (entries != null && entries.Length > 0)
                    {
                        foreach (string key in entries)
                        {
                            string lkey = key;
                            if (_isKeyCaseSensetive)
                            {
                                lkey = key.ToLower();
                            }

                            _settings[section][lkey] = ini.GetValue(section, key).ToString();
                        }
                    }
                }
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Intializes the CINI class and loads its section in an array named _sections
        /// </summary>
        /// <returns></returns>
        private CINI GetINIObject(bool ReadOnly)
        {
            CINI ini = new CINI(_fileName, _encode, ReadOnly);

            _sections = ini.GetSectionNames();
            return(ini);
        }
예제 #3
0
        public bool Save(string section)
        {
            CINI ini = GetINIObject(false);

            if (ini != null)
            {
                return(Save(ini, section));
            }
            return(false);
        }
예제 #4
0
 private void Reset(CINI ini)
 {
     _settings.Clear();
     if (_sections != null && _sections.Length > 0)
     {
         foreach (string itm in _sections)
         {
             AddSection(itm);
         }
     }
 }
예제 #5
0
        /// <summary>
        /// Loads the content of a particular section from the INI file.
        /// </summary>
        /// <param name="section">Name of the section from where to load the settings.</param>
        /// <returns></returns>
        public bool Load(string section)
        {
            CINI ini = GetINIObject(false);

            if (ini != null)
            {
                Reset(ini);
                return(Load(ini, section));
            }
            return(false);
        }
예제 #6
0
        public bool Save()
        {
            CINI ini = GetINIObject(false);

            if (ini != null)
            {
                foreach (string section in _settings.Keys)
                {
                    Save(ini, section);
                }
                return(true);
            }

            return(false);
        }
예제 #7
0
 /// <summary>
 /// Saves the content of the INI file
 /// </summary>
 /// <param name="ini"></param>
 /// <param name="section"></param>
 /// <returns></returns>
 private bool Save(CINI ini, string section)
 {
     if (ini != null)
     {
         //load the section contain only if the section exists.
         if (_settings.ContainsKey(section))
         {
             //saving each key and its value in ini file.
             foreach (KeyValuePair <string, string> item in _settings[section])
             {
                 ini.SetValue(section, item.Key, item.Value);
             }
         }
     }
     return(true);
 }
예제 #8
0
        /// <summary>
        /// Loads all the settings from INI file.
        /// </summary>
        /// <returns></returns>
        public bool Load()
        {
            CINI ini = GetINIObject(false);

            if (ini != null)
            {
                Reset(ini);

                if (_sections != null && _sections.Length > 0)
                {
                    foreach (string section in _sections)
                    {
                        Load(ini, section);
                    }
                    return(true);
                }
            }

            return(false);
        }