Serializer.overrideSerializer

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

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

Parameters

dg void delegate

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

Examples

class Base {}
class Foo : Base {}

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

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

Serializer.registerSerializer!(Foo)(dg);

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

serializer.overrideSerializer!(Foo)(overrideDg);

Meta