Serializer.overrideDeserializer

Overrides a globally registered deserializer for the given type with a deserializer local to the receiver.

The receiver will first check if a local deserializer is registered, otherwise a global deserializer will be used (if available).

  1. void overrideDeserializer(void delegate(ref Base, Serializer, Data) dg)
    class Serializer
    void
    overrideDeserializer
    (
    Derived
    Base
    )
    (
    void delegate
    (
    ref Base
    ,,)
    dg
    )
    if (
    is(T == class) ||
    is(T == interface)
    )
  2. void overrideDeserializer(void delegate(ref T, Serializer, Data) dg)
  3. void overrideDeserializer(void function(ref Base, Serializer, Data) func)
  4. void overrideDeserializer(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.registerSerializer!(Foo)(dg);

auto overrideDg = (ref Base value, Serializer serializer, Data key) {
    // this will override the above deserializer
};

serializer.overrideSerializer!(Foo)(overrideDg);

Meta