I'm trying to implement a custom configuration solution for an asp.net project I'm currently involved in.
Here is the configuration declaration
<sectionGroup name="WebsiteConfig" type="{namespace}.{class}, {assembly}">
<section name="Languages" type="{namespace}.{class}, {assembly}"/>
<section name="LinkFormats" type="{namespace}.{class}, {assembly}"/>
<section name="Countries" type="{namespace}.{class}, {assembly}"/>
</sectionGroup>
with this being the actual configuration I'm trying to use
<WebsiteConfig>
<Languages>
<Language code="en" domain="...">
<Theme .../>
<SiteMap ..."/>
</Language>
<Language code="de" domain="...">
<Theme .../>
<SiteMap .../>
</Language>
</Languages>
<Countries>
<Country Code="UK">
<Files>
<File name="..." fileUrl="..." enabled="true" />
<File ... />
</Files>
<Messages>
<Message Enabled="true" Message="..." />
<Message ... />
</Messages>
</Country>
<Country Code="...">....</Country>
</Countries>
<LinkFormats UseRewrites="false">
<Link name="..." format="..." formatRewrite=".../"/>
<link .... />
</LinkFormats>
</WebsiteConfig>
The problem I'm having is that the Files and Messages collections inside of the Country element (ConfigurationElement) throws an Unrecognised element 'File' etc.
My country element has the following properties for Files and Messages
[ConfigurationProperty("Files")]
public FilesSection Files
{
get
{
return (FilesSection)this["Files"];
}
set
{
this["Files"] = (object)value;
}
}
[ConfigurationProperty("Messages")]
public MessagesSection Messages
{
get
{
return (MessagesSection)this["Messages"];
}
set
{
this["Messages"] = (object)value;
}
}
FilesSection and MessagesSection are both derived from ConfigurationElement with a default collection of type x, which is a collection of items derived from ConfigurationElement.
Does anyone have an insight into where I've gone wrong?
Do I need to turn Countries and Country into SectionGroup's and then turn Files and Messages into Section's?