Summary
This chapter introduced the topic of object serialization services. As you have seen, the .NET platform makes use of an object graph to correctly account for the full set of related objects that are to be persisted to a stream. As long as each member in the object graph has been marked with the [Serializable] attribute, the data is persisted using your format of choice (binary, SOAP, or XML).
You also learned that it is possible to customize the out-of-the-box serialization process using two possible approaches. First, you learned how to implement the ISerializable interface (and support a special private constructor) to become more involved with how formatters persist the supplied data. Next, you came to know a set of new attributes introduced with .NET 2.0, which simplifies the process of custom serialization. Just apply the [OnSerializing], [OnSerialized], [OnDeserializing], or [OnDeserialized] attribute on members taking a StreamingContext parameter, and the formatters will invoke them accordingly. The chapter wrapped up with an examination of a final attribute, [OptionalField], which can be used to gracefully version a serializable type.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2005 Andrew Troelsen
About this chapter
Cite this chapter
(2005). Understanding Object Serialization. In: Pro C# 2005 and the .NET 2.0 Platform. Apress. https://doi.org/10.1007/978-1-4302-0060-4_17
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0060-4_17
Publisher Name: Apress
Print ISBN: 978-1-59059-419-3
Online ISBN: 978-1-4302-0060-4
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books