I have (hopefully) setup ConfigurationElementCollection of my own design with emails as keys. Now what? Hard to find actually on the web. How do I:
iterate through it?
See if a specific element exists?
get a specific element?
...given:
YourConfigElement config =
ConfigurationManager.GetSection("YourSectionName") as YourConfigElement;
Partial answer
1.
foreach (X x in config.XCollection)
<code here>
2 . replace "code here" with
{
if (x.Y == needle)
{
hasIndeed = true;
break;
}
}
3 . replace "code here" with
{ if (x.Y == needle)
cameUpWith = x;
break;
}
Tiny odor.
I don't totally understand what your issues are - but basically, if you have a custom configuration element, you should be able to retrieve that from the config file using something like:
Once you have your configuration element, you can do with it whatever you like - you can implement all those things you asked for - check existance of an element, get a specific element etc.
You should also check out Jon Rista's three-part series on .NET 2.0 configuration up on CodeProject for more information - maybe those articles will help you unlock your config "challenge" ;-)
Highly recommended, well written and extremely helpful!
And if you haven't discovered it already - there's an excellent Configuration Section Designer up on Codeplex which makes visually designing configuration sections and collections a snap and writes all the gooey glue code for you - very handy indeed!
Marc