Table of Contents

Interface IMessagePackSerializationCallbacks

Namespace
Nerdbank.MessagePack
Assembly
Nerdbank.MessagePack.dll

An interface that only reference types may implement to receive callbacks before serialization and after deserialization.

public interface IMessagePackSerializationCallbacks

Remarks

This interface is only supported on reference types. Object map and array converters invoke OnBeforeSerialize(), OnAfterSerialize(), OnBeforeDeserialize(), and OnAfterDeserialize() on the result of casting the value to IMessagePackSerializationCallbacks. When the implementing type is a struct or record struct, that cast boxes a copy, so mutations made by those methods are lost. Implement this interface on a class or record class. A struct that implements this interface produces diagnostic NBMsgPack120.

Methods

OnAfterDeserialize()

Performs any additional operations on an object after it has been deserialized.

void OnAfterDeserialize()

OnAfterSerialize()

Performs any additional operations on an object after it is serialized.

void OnAfterSerialize()

OnBeforeDeserialize()

Performs any additional operations on an object before any properties are set.

void OnBeforeDeserialize()

Remarks

A converter may not call this method if it is not supported. In particular, types with required or init properties or a deserializing constructor should expect this method to not be called if the default converter is used.

OnBeforeSerialize()

Performs any additional operations on an object before it is serialized.

void OnBeforeSerialize()