I am programmatically generating a config file.
Program.cs
string config = new ConfigBuilder().GenerateConfigFile(false);
ConfigBuilder.cs
public string GenerateConfigFile(bool isSettingEnabled)
{
return "<configuration>...</configuration>";
}
Result
<configuration>
<appSettings>
<add key="IsSettingEnabled" value="false" />
</appSettings>
</configuration>
Using something like the ConfigurationManager, I was hoping to read settings from the config variable without first having to write a file to disk. In other words do something like:
ConfigurationManager.OpenFromMemory(config);
var isSettingEnabled = ConfigurationManager.AppSettings["IsSettingEnabled"];
However it seems that the ConfigurationManager can only deal with files.
Is there an easy way to interpret the config without having to parse the XML myself?