Skip to content

Create ShapeshifterSerializer

Csaba Nemes edited this page Jan 16, 2015 · 2 revisions

Create a serializer

The simplest way is to create an instance of ShapeshifterSerializer using the generic class with parameterless constructor.

 var serializer = new ShapeshifterSerializer<MyClass>();

The serializer will walk the object graph starting with MyClass to process all classes which needs to be serialized/deserialized. It also looks for custom serializers and deserializers ([Deserializer] and [Serializer] attributes on methods) in these classes.

Create a serializer with known types

If a type can not be detected during the graph walk you must specify it as a known type when constructing the serializer.

 var serializer = new ShapeshifterSerializer<MyClass>(new[] { typeof(CustomDeserializersForV4) });

Specifying known types is needed if the custom deserializer is in a separate class, or if you use object as type for a serialized field.

Create a serializer with descendant search assemblies

See Advanced Topics when to use descendant search assemblies.

Clone this wiki locally