bool UpdateIniSettings () { if (IniFileManager.IniFileExists ().IsFalse ()) { IniFileManager.SaveChanges (); // create empty INI file } Model.Result.CopyFrom (IniFileManager.ValidatePath ()); if (Model.Result.IsValid) { // first time only if (IniFileManager.ContainsSection (TProcess.PROCESSMODULESSECTION).IsFalse ()) { // Module Process section var token = IniFileManager.AddSection (TProcess.PROCESSMODULESSECTION); TIniFileManager.AddTrailingComment (token, "Module Process"); // comment. // Process Names section token = IniFileManager.AddSection (TProcess.PROCESSNAMESSECTION); TIniFileManager.AddTrailingComment (token, "Process Names"); // comment. // key (all process names separated by '?') TIniFileManager.AddKey (token, TProcess.PROCESSNAMES, Model.RequestAllProcessNames ()); foreach (var process in Model.RequestProcess ()) { var section = process.Key.ToString (); var key = process.Value.ToString (CultureInfo.InvariantCulture); // section (Process name) token = IniFileManager.AddSection (section); // key TIniFileManager.AddKey (token, TProcess.PROCESSISALIVE, key); TIniFileManager.AddKey (token, TProcess.PALETTETHEME, string.Empty); TIniFileManager.AddKey (token, TProcess.PALETTEPRIMARY, string.Empty); TIniFileManager.AddKey (token, TProcess.PALETTEACCENT, string.Empty); } } // update ini else { foreach (var process in Model.RequestProcess ()) { var section = process.Key.ToString (); var key = process.Value.ToString (CultureInfo.InvariantCulture); // key IniFileManager.ChangeKey (section, TProcess.PROCESSISALIVE, key); } } IniFileManager.SaveChanges (); } return (Model.Result.IsValid); }
public bool Validate () { bool res = false; Result.CopyFrom (IniFileManager.ValidatePath ()); // file found if (Result.IsValid) { // create new section if (IniFileManager.ContainsSection (SupportSection).IsFalse ()) { var token = IniFileManager.AddSection (SupportSection); foreach (var settingsName in m_SupportSettingsData.SettingsNames) { var keyName = settingsName; var keyValue = TSupportSettingsData.Request (settingsName); TIniFileManager.AddKey (token, keyName, keyValue); } IniFileManager.SaveChanges (); } // update support settings data else { foreach (var settingsName in m_SupportSettingsData.SettingsNames) { if (IniFileManager.ContainsKey (SupportSection, settingsName)) { var settingsValue = IniFileManager.RequestKey (SupportSection, settingsName); TSupportSettingsData.Select (settingsName, settingsValue); } } } res = true; } return (res); }