| 1 | = HeuristicLab Persistence Quick Start Guide = |
| 2 | |
| 3 | == Invocation == |
| 4 | Use the classes `XmlGenerator` and `XmlParser` to transform an object graph into XML and read it back again. You can serialize into a file that is essentially a ZIP file with two entries or directly to a stream. |
| 5 | |
| 6 | == Custom Classes == |
| 7 | * Add the `[StorableClass]` attribute to your class |
| 8 | * Add the `[Storable]` attribute to any fields or properties you would like to be persisted |
| 9 | * Choose a constructor that is available to the persistence: |
| 10 | * Either a default constructor with no arguments (can be private) |
| 11 | * Or a `[StorableConstructor]` with a single bool argument (e.g. `isDeserializing`) that is set to true when invoked by the persistence |
| 12 | |
| 13 | If you need more logic you can add a `[PersistenceHook]` attribute to parameterless methods that will be called before serialization start or after serialization finishes for an object. |
| 14 | |
| 15 | == Support for Other Classes == |
| 16 | * An `IPrimitiveSerializer` directly transforms an object and its components into serialized form. This is mainly used for primitive types such as int or float. |
| 17 | * An `ICompositeSerializer` does not directly transform an object into serialized form but decomposes it into other objects that can then be used to recompose the same object. |
| 18 | |
| 19 | == Other Formats == |
| 20 | You can use the core persistence components to generate other formats. This is done through a stream of serialization tokens. The `Serializer` and `Deserializer` use classes of type `ISerializationToken` to talk to the back end. They describes a hierarchical format of composites that can contain other composites, primitives or references. Additionally, type information and is conveyed in type information tokens. |