/// <summary> /// Removes all INI keys that were removed as config keys. /// </summary> private void RemoveConfigKeys(IConfig config) { IniSection section = iniDocument.Sections[config.Name]; // Remove old keys string[] configKeys = config.GetKeys(); foreach (string configKey in configKeys) { if (!section.Contains(configKey)) { // Key doesn't exist, remove config.Remove(configKey); } } // Add or set all new keys string[] keys = section.GetKeys(); for (int i = 0; i < keys.Length; i++) { string key = keys[i]; config.Set(key, section.GetItem(i).Value); } }
/// <summary> /// Loads the configuration file. /// </summary> private void Load() { IniConfig config = null; IniSection section = null; IniItem item = null; for (int j = 0; j < iniDocument.Sections.Count; j++) { section = iniDocument.Sections[j]; config = new IniConfig(section.Name, this); for (int i = 0; i < section.ItemCount; i++) { item = section.GetItem(i); if (item.Type == IniType.Key) { config.Add(item.Name, item.Value); } } this.Configs.Add(config); } }