persistence/serializable
Peter Osucha <[email protected]> Tue, 27 Mar 2007 14:54:00 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <[email protected]> |
I have a two objects - Step and Composite Step has a few string and int properties - nothing too fancy. Composite has a few string properties and an ArrayList of Step objects. I am looking at XML as an easy way to persist some user configurations of Step and Composite instances to files. So I marked these classes with [Serializable] and created Serialize() and Deserialize() methods. The instances were serialized and deserialized - however, this methodology didn't do exactly what I want. If I call the Serialilze() or Deserialize() methods on the Step object, I save or restore the Step instance I desire (all the properties are saved as I desire). If I call the Serialize() or Deserialize() methods on the Composite object, I save or restore the Composite instance I desire EXCEPT that the individual Step instances (and all their settings) are also saved (ie, the ArrayList of Step objects is serialized). What I'd prefer is to just save and restore the Step 'names' in the Serialize() and Deserialilze() methods and not all the information that defines each of the Step instances (the Step instance properties might change and the Composite object needs to always refer to the current Step properties - not any that might have existed in the past when the Serialize() method for the Composite instance was called). I can't come up with a way to mark 'something' with the [NonSerialized] attribute that does what I need. Any ideas, please? Peter =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com