472,146 Members | 1,682 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

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 3318
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
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.