User-1086189402 posted
Hello,
I want to define more than one section inside sectionGroup.Its my config section
<configSections>
<sectionGroup name="CredentialsGroup">
<section name="Credentials"
type="CustomConfiguration.CredentialsSection"
allowDefinition="Everywhere"
allowLocation="true"
/>
</sectionGroup>
</configSections>
I have this format of section
<CredentialsGroup>
<Credentials>
<company name="Carolina" userid="abc" password="abc"></company>
<file name="dfbf0f94-767e-4c71-b4ee-2dc05fb76e3c.csv"
url="https://e.brightree.net/Home/Filecsv"></file>
<company name="Asbury" userid="dd" password="dd"></company>
<file name="dfbf0f94-767e-4c71-b4ee-2dc05fb76e3c.csv"
url="https://e.brightree.net/Home/File.csv"></file>
</Credentials>
</CredentialsGroup>
and this is my customconfiguration class
public class CredentialsSection: ConfigurationSection
{
[ConfigurationProperty("company",IsRequired=true)]
public CompanyElement Company
{
get {
return (CompanyElement)this["company"];
}
set
{
this["company"] = value;
}
}
[ConfigurationProperty("file",IsRequired=true)]
public FileElement File
{
get
{
return (FileElement)this["file"];
}
set
{
this["file"] = value;
}
}
}
public class CompanyElement : ConfigurationElement
{
[ConfigurationProperty("name",IsRequired=true)]
public string Name
{
get {
return (string)this["name"];
}
set
{
this["name"] = value;
}
}
[ConfigurationProperty("userid", IsRequired = true)]
public string UserId
{
get
{
return (string)this["userid"];
}
set
{
this["userid"] = value;
}
}
[ConfigurationProperty("password", IsRequired = true)]
public string Password
{
get
{
return (string)this["password"];
}
set
{
this["password"] = value;
}
}
}
public class FileElement : ConfigurationElement
{
[ConfigurationProperty("name", IsRequired = true)]
public string Name
{
get
{
return (string)this["name"];
}
set
{
this["name"] = value;
}
}
[ConfigurationProperty("url",IsRequired=true)]
public string Url
{
get
{
return (string)this["url"];
}
set {
this["url"] = value;
}
}
}
I want a format like the one I've defined in web.config file. 'Company' and 'File' nodes should be siblings and extraction of nodes will be conditional dependent on companyname like
ConfigurationManager.GetSection("CredentialsGroup/Credentials/company['name']=" + companyName);
but its not allowing me to define multiple section...Please Help