Groups | Blog | Home
all groups > dotnet xml > may 2004 >

dotnet xml : XmlSerializer with object derived from CollectionBase


eastsh
5/13/2004 10:30:54 PM
I have been looking into using the MS application block for
configuration management, and I am very happy with the options it
provides. Since it stores hashtables, I decided that for configuration
data my app needs, I would create strongly typed collections for each
config type. For instance, CarCollection dervied from CollectionBase
which only accepts items of Car would be set to hashtable key "AppCars".

I am running into all kinds of hurdles trying to get the hashtable
serialized. The app block takes care of converting the hashtable to an
XmlNode collection I believe, but I am wondering what is going on with
my collection. I guess my questions would break down as this:

1. Is it recommended that XmlSerializer be used to store collection
objects that derive from CollectionBase and contain strongly typed values?

2. Are there any articles that would help me?

I have read enough to know that XmlSerializer wants a public property
"Count" of type int, and a public Indexer for the collection which has
to return the same type that Add requires, which I took care of.

Ross Donald
6/6/2004 2:28:24 PM
I do not think that the XmlSerializer supports hashtables. See this thread:

http://groups.google.com.au/groups?hl=en&lr=&ie=UTF-8&threadm=eSqOZIZXCHA.1660%40tkmsftngp09&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26q%3Dhashtable%2BXmlSerializer

--
Ross Donald
Rad Software
Free Regular Expression Designer @
http://www.radsoftware.com.au/web/Products/


[quoted text, click to view]
| I have been looking into using the MS application block for
| configuration management, and I am very happy with the options it
| provides. Since it stores hashtables, I decided that for configuration
| data my app needs, I would create strongly typed collections for each
| config type. For instance, CarCollection dervied from CollectionBase
| which only accepts items of Car would be set to hashtable key "AppCars".
|
| I am running into all kinds of hurdles trying to get the hashtable
| serialized. The app block takes care of converting the hashtable to an
| XmlNode collection I believe, but I am wondering what is going on with
| my collection. I guess my questions would break down as this:
|
| 1. Is it recommended that XmlSerializer be used to store collection
| objects that derive from CollectionBase and contain strongly typed values?
|
| 2. Are there any articles that would help me?
|
| I have read enough to know that XmlSerializer wants a public property
| "Count" of type int, and a public Indexer for the collection which has
| to return the same type that Add requires, which I took care of.
|
| Any suggestions? Seems like a reasonable thing to me..

AddThis Social Bookmark Button