You are here: AxTools > CodeSMART 2009 for VS.NET > Documentation > User's Guide > Advanced Code Builders > Implementing Object Serialization and Deserialization
While browsing this page, why not start downloading the evaluation setup kit (direct download, no questions asked).

Implementing Object Serialization and Deserialization
Applies to: Visual Studio .NET 2002, Visual Studio .NET 2003, Visual Studio 2005, Visual Studio 2008

Serialization is the term used for the act of persisting (saving) an object to a storage medium - a file, a database or even main memory. The purpose is to be able to re-create an object instance that can be considered identical to the original (through a process called deserialization) and later use it into the same or another application domain. The .NET Framework knows how to serialize basic data types, but if you want to serialize custom fields in your own types then you must implement the ISerializable interface and a specialized deserialization constructor.

To implement serialization and deserialization code for an already defined type:

  1. Open the Visual Basic or C# component containing the type you want to implement serialization and deserialization code for and place the cursor inside that type's code.
  2. In the CodeSMART main menu, select the Implement Object Serialization and Deserialization entry from the Code Builder Tools popup menu, Implement Advanced Code secondary popup, or choose the Object Serialization and Deserialization entry from the Implement toolbar popup (quick toolbar and menu references are available).

    The Implement Object Serialization and Deserialization dialog will be displayed:
  3. Select the type fields for which you want serialization/deserialization code to be implemented for.
  4. In the Serialization and/or deserialization section, specify the features you want your type to be able to provide:
    • read:
    • check the Add deserialization constructor option.
    • write:
    • check the Add the GetObjectData serialization method option.

  5. Generate XML comments: check this option if you want XML descriptive comments to be generated for the newly inserted code.
  6. You can enclose the generated code between #Region and #End Region directives by checking the corresponding option.
  7. Press the Standards button in order to review the naming standards configuration since this one will be considered when generating code.
  8. Press Insert to generate and insert the desired code based on the above specified settings.
See Also
Advanced Code Builders Overview
Implementing Interfaces
Implementing Object Construction and Destruction
Implementing Common Object Operations
Implementing Member Override
Implementing Event Definitions in C#
Inserting Custom Attribute Classes
Inserting Custom Exception Classes
Inserting Custom Formatter Classes
Inserting Strongly Typed Collection Classes

Back to top