Serializer.registerDeserializer

Registers a deserializer for the given type.

The given callback will be called when a value of the given type is about to be deserialized. This method can be used as an alternative to register. This method can also be used as an alternative to Serializable.fromData.

This is method should also be used to perform custom deserialization of third party types or when otherwise chaining an already existing type is not desired.

  1. void registerDeserializer(void delegate(ref Base, Serializer, Data) dg)
    class Serializer
    static
    void
    registerDeserializer
    (
    Derived
    Base
    )
    (
    void delegate
    (
    ref Base
    ,,)
    dg
    )
    if (
    is(T == class) ||
    is(T == interface)
    )
  2. void registerDeserializer(void delegate(ref T, Serializer, Data) dg)
  3. void registerDeserializer(void function(ref Base, Serializer, Data) func)
  4. void registerDeserializer(void function(ref T, Serializer, Data) func)

Parameters

dg void delegate
(
ref Base
,,)

the callback that will be called when value of the given type is about to be deserialized

Examples

class Base {}
class Foo : Base {}

auto archive = new XmlArchive!();
auto serializer = new Serializer(archive);

auto dg = (ref Base value, Serializer serializer, Data key) {
    // perform deserialization
};

Serializer.registerDeserializer!(Foo)(dg);

See Also

register registerSerializer Serializable.fromData

Meta