1. Home
  2. Docs
  3. Serialization
  4. Custom Type Serialization

Custom Type Serialization

Mark Types, you want to serialize, with the Attribute ‘SerializeAbleClass’ which can be found in ‘OPS.Serialization.Attributes’. But only adding this Attribute will not save any fields.

To save fields you have to mark them with the Attribute ‘SerializeAbleField’, which can be found too in the namespace OPS.Serialization.Attributes’.

The field type has to be a one of the types found here or a class marked by you as ‘SerializeAbleClass’. The ‘SerializeAbleField’ has a parameter called Index. This Index has to be a unique integer, used as key to identify the field. Start at best at zero.

To allow inheritance you have to add the Attribute ‘ClassInheritance’ on the base class. For example: The ‘Teacher’ is serializable class and inherites from the serializeable ‘Person’ class. So the ‘Person’ class needs an ‘ClassInheritance’ to ‘Teacher’.

As you can see you need to link to the type and you have to enter an increasing Index like you know from
the ‘SerializeAbleField’ Attribute. These Indexes are independent from the ones used for the fields. So they can share the same integer values you used for the fields. And vice versa.



Note: You need only the ‘SerializeAbleClass’ Attribute or the ‘ClassInheritance’ Attribute in the inheritance chain if this class serializes something. If it does not, you have not to add it.