Custom Serialization
In most cases the .NET built-in serialization engine is good enough. But if it does not meet your particular needs, you can override the serialization process with custom serialization. Basically this means implementing the ISerializable
interface that requires the implementation of the GetObjectData
method. Such a method is important because it is invoked during serialization. Moreover a custom implementation of the class constructor must be provided. Basically you have to first reproduce at least what built-in formatters do during serialization. Code in Listing 43.2 shows how to provide custom serialization for the Person
class.
The GetObjectData
method is basically invoked ...
Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.