I need to break application settings in two files, one for external resources access, like a share folder or a web service url, and other for all the rest.
To keep configuration access simple in code i added a new Settings file, called ExternalResourceSettings
. These settings files are derive from ApplicationSettingsBase
.
How can i load an object of this class from a specific configuration file?
For clarification, the ExternalResourceSettings looks like these:
internal sealed partial class ExternalResourceSettings: global::System.Configuration.ApplicationSettingsBase {
...
}
ConfigurationManager class can load any config file to a Config object in 3 lines:
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = "Some path";
// Get the mapped configuration file
var config =ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
But how to convert it to ExternalResourceSettings? Or can ExternalResourceSettings be loaded from a specific file in a other way?
Note: ExternalResourceSettings default constructor reads from default configuration file.