I,

By default, the XmlSerializer will be able to serialize your class, with
no modifications to it (which means, no extra attribute).
However, it's not going to serialize an IDictionnary (HashTable,
SortedList, etc).  In that case, your collection should implement
ICollection (all un-keyed collections, like ArrayList).  Or, you may as
well save you .values and .keys collections of the IDictionnary separately
to disk, but you will have to manually loop to reconstruct the original
collection.

All you have to do is to instantiate an XmlSerializer (using the
XmlSerializerFactory for .net 2.0), giving it the type of your collection
at construction time.  The framework is then going to, behind the scenes,
build a dll that will be in charge of persisting and unpersisting the
object.

Good luck!

Dave.
http://omniscient.ca


> Hello all,
>
>      I am looking for a solution to saving the contents of a collection
> of objects to disk and then reading the data back into the collection.
>
>         Suppose I have this collection called "Col" and each item is an
> object called "ID". The ID object has two properties called "Name" and
> "Address". The Col has 1 ... n number of ID objects. What I would like
> to do is save the entire collection to a disk file and at some later
> time, retrieve the values back into the collection. Naturally, the
> program stops after the save and then, perhaps, the next day it is
> started up again.
>
>       I think the Serialization attribute plays a big part in this, but
> frankly I don't know how to use that attribute nor be able to read the
> serialized data back in.
>
>       May I ask for someone to point me to some possible on line
> solutions or if this is relatively simple, show me how it might be done?
>
>
> Thank you very much.
>
>
> Best regards,
>
>
> Jerry Knowlton
>
> ===================================
> This list is hosted by DevelopMentor®  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to