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); }
/// <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); }
public bool Save(string section) { CINI ini = GetINIObject(false); if (ini != null) { return(Save(ini, section)); } return(false); }
private void Reset(CINI ini) { _settings.Clear(); if (_sections != null && _sections.Length > 0) { foreach (string itm in _sections) { AddSection(itm); } } }
/// <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); }
public bool Save() { CINI ini = GetINIObject(false); if (ini != null) { foreach (string section in _settings.Keys) { Save(ini, section); } return(true); } return(false); }
/// <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); }
/// <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); }