Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Member nameGets serialized
_fieldValue
RegularProperty
CatelProperty

Serializing a ModelBase as collection

There is a very edge case that a class derives from ModelBase, but also implements IList<T>. In this case, it's hard for the serializers to determine what to do. By default, it will treat the model as a Catel model (since it can contain more properties than just the Items property. If such a class should be serialized as collection (meaning it will only serialize the Items property), decorate it with the SerializeAsCollection attribute:

 

Code Block
[SerializeAsCollection]
public class MyModel : ModelBase, IList<int>
{
    // implementation left out for readability
}

Implementing a custom ISerializationManager

...