O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Perform Selective Serialization with the Memento Pattern

Problem

You want to serialize only part of an object or an object that inherits from another nonserializable object.

Solution

Create a dedicated, serializable object to hold the information that must be persisted.

Discussion

The memento pattern allows you to handle object serialization in a more flexible manner. Some of the reasons you might use the memento pattern include the following:

  • You want to serialize an object that wouldn’t otherwise be serializable (perhaps because it derives from a nonserializable object).

  • You want to serialize a portion of an object. The NonSerialized attribute can also help in this case, but you can’t use it to prevent the serialization of the information in a class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required