Table of Contents

Class DefaultPayloadConverter

Namespace
Temporalio.Converters
Assembly
Temporalio.dll

Default implementation of a payload converter which iterates over a collection of IEncodingConverter.

public class DefaultPayloadConverter : IPayloadConverter
Inheritance
DefaultPayloadConverter
Implements
Inherited Members
Extension Methods

Remarks

See DefaultPayloadConverter() for the default set of encoding converters used. To create a custom converter, a new class should extend this one.

Constructors

DefaultPayloadConverter()

Initializes a new instance of the DefaultPayloadConverter class.

public DefaultPayloadConverter()

Remarks

The default payload converter uses the following set of payload converters in order:

Each of those converters are tried in that order when converting to payload, stopping at the first one that can convert. This means nulls, byte arrays, and protobuf messages are all have their own encoding and anything else falls through to the JSON converter. The JSON converter will fail on anything it can't convert.

This also means binary proto converter will never be used when converting to a payload since the JSON proto converter will accept proto objects first. It is present however for converting from payloads which may have its encoding (e.g. from another language that is using binary proto instead of JSON proto).

DefaultPayloadConverter(JsonSerializerOptions)

Initializes a new instance of the DefaultPayloadConverter class.

protected DefaultPayloadConverter(JsonSerializerOptions jsonSerializerOptions)

Parameters

jsonSerializerOptions JsonSerializerOptions

Custom serializer options.

Remarks

This is protected because payload converters are referenced as class types, not instances, so only subclasses would call this.

See Also

DefaultPayloadConverter(params IEncodingConverter[])

Initializes a new instance of the DefaultPayloadConverter class with a set of encoding converters.

protected DefaultPayloadConverter(params IEncodingConverter[] encodingConverters)

Parameters

encodingConverters IEncodingConverter[]

Encoding converters to use. Duplicate encodings not allowed.

Remarks

This is protected because payload converters are referenced as class types, not instances, so only subclasses would call this.

See Also

Properties

EncodingConverters

Gets the encoding converters tried, in order, when converting to payload.

public IReadOnlyCollection<IEncodingConverter> EncodingConverters { get; }

Property Value

IReadOnlyCollection<IEncodingConverter>

IndexedEncodingConverters

Gets the encoding converters by encoding looked up when converting from payload.

protected IReadOnlyDictionary<ByteString, IEncodingConverter> IndexedEncodingConverters { get; }

Property Value

IReadOnlyDictionary<ByteString, IEncodingConverter>

Methods

ToPayload(object?)

Convert the given value to a payload.

public Payload ToPayload(object? value)

Parameters

value object

The value to convert.

Returns

Payload

The converted payload.

Remarks

Implementers are expected to be able just return the payload for IRawValue.

ToValue(Payload, Type)

Convert the given payload to a value of the given type.

public object? ToValue(Payload payload, Type type)

Parameters

payload Payload

The payload to convert.

type Type

The type to convert to.

Returns

object

The converted value.

Remarks

Implementers are expected to be able to support types of IRawValue.