How to serialize properties excluded from serialization in catel?

136 Views Asked by At

In my modelbase, I have properties that are of type Color and of type Thickness. The serialization manager has noted that these properties are to be excluded from serialization. I'd like to provide a method to serialize these properties.

Is there a way I can register a method to serialize these properties, so the manager will not exclude them?

1

There are 1 best solutions below

3
On

See the documentation:

  1. Specifying what gets serialized

Basically means that you can decorate any property, field, etc using the [IncludeInSerialization] attribute to get it included by the serialization engine.

  1. Customizing serialization

Shows how to create a serializer modifier to allow to modify a value before serialization and after deserialization. This means you can convert a Color to a string.Format("{0}|{1}|{2}|{3}", c.A, c.R, c.G, c.B);. When deserializing, you can easily parse this yourself and get the color back. This allows you the serialize anything.