Home All Groups Group Topic Archive Search About

Re: Question on ConfigurationElementCollection design

Author
10 Jul 2006 2:35 PM
mbu27
A while back, a question was posted on ConfigurationElementCollection design as follows:

"I have 2 questions on using element collections when building a custom
section handler.  I'm using the "declarative" model and I can post the code
if necessary. 

My code works and the XML in app.config for my custom section looks like this:

MySection name="x"
    Stores add name="store1" 
           add name="store2" 
    Stores
MySection

But I have 2 sort of "cosmetic" questions about changing the XML:

1. 
....

2. In some cases it might also be nicer to skip the outermost "Stores"
element and just have this:

MySection name="x"
     Store name="store1"      Store name="store2"
MySection

But I don't see how to arrange for this in the declarations of a
ConfigurationElementCollection.  It seems to require the outermost element to
key on its name.  What I want is sort of an "unnamed" collection of Stores."

The first part of the question was answered by using the ConfigurationCollection attribute.

Did you ever get a solution to the "unnamed" part (part 2) of your question? I'd like to also add a section collection to my config section and adding a name is redundant. ie., the "Stores" element in you sample. Can an "unnamed" section be added?

AddThis Social Bookmark Button