I have a customized config section in my web.config like this:
<configSection>
<section name="CustomConfig" type="ConfigSectionRoot" allowLocation="true" allowDefinition="Everywhere"/>
</configSection>
<CustomConfig>
<ConfigRoot>
<add key="DataBase" value="CouchDB"/>
<add key="FrontEnd" value="Asp.Net"/>
<add key="AppName" value="Virtual WorkPlace"/>
</ConfigRoot>
</CustomConfig>
<AppSettings>
<add key="DataBase" value="CouchDB"/>
</AppSettings>
My ConfigSectionRoot.cs is like this:
public class ConfigSectionRoot:ConfigurationSection
{
[ConfigurationProperty("key", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Key
{
get
{
return ((string)(base["key"]));
}
set
{
base["key"] = value;
}
}
[ConfigurationProperty("value", DefaultValue = "", IsKey = false, IsRequired = false)]
public string Value
{
get
{
return ((string)(base["value"]));
}
set
{
base["value"] = value;
}
}
}
If i use AppSettings Instead of Custom Config I could access it like:
string results= ConfigurationManager.AppSettings["Database"];
// results wil contain "CouchDB"
Is there any way to achieve the same thing in Customized Config section ??? Pls help me out