Working with configuration files
When working with configurations you can retrieve and modify configuration values. Depending on your specific needs you operate with configuration values with different managers:
Reading configuration values
To read configuration values you use Telerik.Sitefinity.Configuration.Config class. Config uses the default provider and is optimized for fast reading. You cannot use the Config class for modifying configurations.
You read a configuration value in the following way:
string theme = Config.Get<AppearanceConfig>().BackendTheme;
To get the configuration file, you use Config.Get and pass the type of the .config file that stores the value. In the example, you read the BackendTheme value from the AppearanceConfig file.
Modifying and saving configuration values
To modify configuration values, you use ConfigManager class.
You modify a configuration value in the following way:
ConfigManager manager = Config.GetManager();
AppearanceConfig section = manager.GetSection<AppearanceConfig>();
section.BackendTheme = "EditorsTheme";
manager.SaveSection(section);
To modify the configuration file, first, you get the configuration manager by calling the GetManager method of the Config class. Then, you use GetSection to get the AppearanceConfig section. Finally, you modify BackendTheme and save the changes.
NOTE: ConfigManager does not support transactions. To save the changes, you call SaveSection by passing the section name.