Long story short, the .Net ConfigurationManager.GetSection
method skips duplicates, and I'm looking for a best practice for handling this. I have a config file that includes something like this:
<views>
<view name="BusinessUnitsView" Desc="desc1"/>
<view name="BusinessUnitsView" Desc="desc2"/>
</views>
I have a graph of objects the config loads onto where collections derive from our derived version of ConfigurationElementCollection
. The views collection in the graph only has one item in it after loading the above--my understanding is that this is simply the way the ConfigurationManager
handled duplicates. The last item with the same key wins.
I could throw an exception on a duplicate being found by using BaseAdd(element, true). However, if possible I'd like to get the object completely loaded WITH duplicates, as the config gets read in a service layer, and I'd like to detect and deal with the problem on the consuming side of the service.
Do I have any options for modifying the way adds to the collection work?