ConfigurationElementCollection - Removable elements
I'm trying to implement custom serialization of a collection derived from ConfigurationElementCollection so that it generates a more appropriate remove tag:
<remove key="mykey"> instead of just <remove/>
This is just like the remove tag which is generated by the ConnectionStringSettingsCollection of the connection strings:
<connectionStrings>
<addname="connection string name"
connectionString="connection string"
providerName="ADO.NET data provider" />
<remove name="connection string name"/>
</connectionStrings>I know can override the SerializeElement of the collection to generate the XML.
My question is:how do I know which elements have been removed?
Enumerating over the collection only returns the elements that the collection contains (not the elements removed).
If I look at the base class in the debugger, I see an Items collection property (and an _items field) that contains all the elements, with the elements removed marked as "removed"... this is exactly what I need... but the property and field are PRIVATE, so I can't access that information.
So, how do I do this? I've tried keeping a list of removed elements myself, but for some obscure reason the serialization mechanism creates a new instance of the ConfigurationElementCollection when it saves the data to disk and any member I use are not cloned in that instance, which gets the SerializeElement call.
I guess there a simple way to do this by simply using the ConfigurationElementCollection members, but I haven't found the way yet.
Thanks
I'm using Visual Studio 2005 Beta 2

