Re: persistence/serializable
Peter Osucha <[email protected]> Wed, 28 Mar 2007 08:20:35 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <[email protected]> |
Thanks Dave and Anthony, I don't like the kludge option - but thanks for the suggestion. It would work but I don't like having that other public property. The 'momento' class (another class that can be serialized as desired and then used to instantiate the real class instance) is, perhaps, a better option. It seems there should be more control built into the [Serializable] attribute and how it is used though. Peter -----Original Message----- From: Discussion relating to the specifics of the C# and Managed C++ languages [mailto:[email protected]] On Behalf Of Davy J Sent: Wednesday, March 28, 2007 4:48 AM To: [email protected] Subject: Re: [DOTNET-CX] persistence/serializable Kludge Option: I don't advocate this approach; but just anoter idea to get you thinking Try marking the Arraylist as [XmlIgnore] then adding another public property that contains a list of strings. in the Get build the list of strings from the array list; in the set build the list of arrayobjects from disk; ONLY if the arraylist is null Dave On 3/27/07, Nassar, Anthony <[email protected]> wrote: > Does anyone know how a way to do this w/o having Component implement > IXmlSerializable? Since nearly every member of that class that you want > to serialize has an acceptable default XML serialization, it shouldn't > be too hard. The only alternative that comes to mind is to use a custom > collection, and *not* ArrayList; then implement IXmlSerializable for > that class (i.e., just write out the names of the Step objects, and just > read those back in. Then the enclosing instance of Component would have > to resolve those references, though, which takes you back to > implementing IXmlSerializable for Component). > > This is why I don't like to make classes serializable. Usually I've got > a "memento" class that the real class can instantiate, or populate > itself from. I design the memento in order to be trivially serializable. =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com