Hi,
I'm trying to build a custom configuration and with some reason, I can't get it work. I'll appreciate if anyone can see where my problem is.
Here is the code:
public class PointServices : ConfigurationSection
{
public static PointServices Get()
{
var t = ConfigurationManager.GetSection("point.Services/xServices") as PointServices;
return t;
}
//<summary>
//Declares a collection element represented in the following configuration sub-section
//<singleInstances> <add .../> </singleInstances>
//</summary>
[ConfigurationProperty("xServices", IsDefaultCollection = true)]
[ConfigurationCollection(typeof(PointServices))]
public PointServicesCollection Services
{
get
{
//var v = base["xServices"];
return (PointServicesCollection) base["xServices"];
}
}
}
public class PointService : ConfigurationElement
{
[ConfigurationProperty("name",IsRequired = true)]
public string Name
{
get
{
return this["name"].ToString();
}
}
[ConfigurationProperty("type", IsRequired = true)]
public string Type
{
get
{
return this["type"].ToString();
}
}
}
and here is the config:
<sectionGroup name="point.Services">
<section name="xServices" type="XYZ.Messaging.PointServiceConfiguration.PointServices, XYZ.Point.Messaging" />
</sectionGroup>
...
<point.Services>
<xServices>
<xService>
<add name="XYZService" type="XYZService" />
</xService>
</xServices>
</point.Services>
When I'm running: PointServices.Get()
, I'm getting:
Unrecognized element 'xService'.
I tried to add xService to the section definition as following:
<section name="xService" type="XYZPoint.Messaging.PointServiceConfiguration.PointService, Barcap.FIA.Point.Messaging" />
but it didn't seem to help.
If anyone has any idea, please help! Thanks