469,908 Members | 2,213 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,908 developers. It's quick & easy.

Deserialize Custom Collection Extending NameObjectCollectionBase

Hi,

I have several custom collections that inherit from
System.Collections.Specialized.NameObjectCollectio nBase and I want to
serialize and deserialize with the XMLSerializer object. This works great
but my problem is that when the deserialization occurs, it uses the default
add method to add objects to the collection without adding the keys.

My question is this. Is there any way to use the XMLSerializer object to
deserialize and inform the deserialization process which attribute or element
should be considered the key and have it call a different add method with the
key? Or what approach do I have to take?

Thanks
Mark Overstreet
Nov 16 '05 #1
1 3242
Mark,

In this case, you might have to implement IXmlSerializable on your
class, and handle the serialization yourself, reading the associated keys,
and then adding them properly to your collection with the values.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark Overstreet" <Mark Ov********@discussions.microsoft.com> wrote in
message news:63**********************************@microsof t.com...
Hi,

I have several custom collections that inherit from
System.Collections.Specialized.NameObjectCollectio nBase and I want to
serialize and deserialize with the XMLSerializer object. This works great
but my problem is that when the deserialization occurs, it uses the
default
add method to add objects to the collection without adding the keys.

My question is this. Is there any way to use the XMLSerializer object to
deserialize and inform the deserialization process which attribute or
element
should be considered the key and have it call a different add method with
the
key? Or what approach do I have to take?

Thanks
Mark Overstreet

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Pavils Jurjans | last post: by
1 post views Thread by igitur | last post: by
2 posts views Thread by A Traveler | last post: by
1 post views Thread by jamie_m_ | last post: by
34 posts views Thread by Craig Buchanan | last post: by
7 posts views Thread by Michael Kellogg | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.