/// <summary> /// Gets the editor configuration value. /// </summary> /// <typeparam name="T">The Type definition.</typeparam> /// <param name="sectionName">Name of the section.</param> /// <param name="key">The key.</param> /// <param name="defaultValue">The default value.</param> /// <returns>The value to get.</returns> public static T GetEditorConfigValue <T>(string sectionName, string key, T defaultValue = default(T)) { string configFilePath = GetConfigFilePath(); IniFileInfo fileInfo = new IniFileInfo(configFilePath); if (fileInfo != null) { IniSectionInfo sectionInfo = fileInfo.GetSection(sectionName); if (sectionInfo != null) { return(sectionInfo.GetValue <T>(key)); } } return(defaultValue); }
/// <summary> /// Sets the editor configuration value. /// </summary> /// <typeparam name="T">The Type definition.</typeparam> /// <param name="sectionName">Name of the section.</param> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <param name="configFileDomain">The configuration file domain.</param> public static void SetEditorConfigValue <T>(string sectionName, string key, T value) { string configFilePath = GetConfigFilePath(); IniFileInfo fileInfo = new IniFileInfo(configFilePath); if (fileInfo != null) { IniSectionInfo sectionInfo = fileInfo.GetSection(sectionName); if (sectionInfo == null) { sectionInfo = new IniSectionInfo(sectionName); fileInfo.AddSection(sectionName, sectionInfo); } sectionInfo.AddOrSetValue(key, value.ToString()); fileInfo.Save(); } }