Table of Contents

Class ConverterExtensions

Namespace
Temporalio.Converters
Assembly
Temporalio.dll

Extensions for data, payload, and encoding converters.

public static class ConverterExtensions
Inheritance
ConverterExtensions
Inherited Members

Methods

ToExceptionAsync(DataConverter, Failure)

Decode and convert the given failure to an exception. Note, the failure object may be mutated in place so callers should clone to avoid side effects.

public static Task<Exception> ToExceptionAsync(this DataConverter converter, Failure failure)

Parameters

converter DataConverter

Converter to use.

failure Failure

Failure to decode and convert. This may be mutated.

Returns

Task<Exception>

Decoded and converted exception.

ToFailureAsync(DataConverter, Exception)

Convert and encode the given exception to failure.

public static Task<Failure> ToFailureAsync(this DataConverter converter, Exception exc)

Parameters

converter DataConverter

Converter to use.

exc Exception

Exception convert and encode.

Returns

Task<Failure>

Converted and encoded failure.

ToPayloadAsync(DataConverter, object?)

Convert and encode the given value to a payload.

public static Task<Payload> ToPayloadAsync(this DataConverter converter, object? value)

Parameters

converter DataConverter

Converter to use.

value object

Value to convert and encode.

Returns

Task<Payload>

Converted and encoded payload.

ToPayloads(IPayloadConverter, IReadOnlyCollection<object?>)

Convert values to payloads only using the payload converter. Most users outside of a workflow should instead use the data converter to convert.

public static IReadOnlyCollection<Payload> ToPayloads(this IPayloadConverter converter, IReadOnlyCollection<object?> values)

Parameters

converter IPayloadConverter

Converter to use.

values IReadOnlyCollection<object>

Values to convert.

Returns

IReadOnlyCollection<Payload>

Converted values.

ToPayloadsAsync(DataConverter, IReadOnlyCollection<object?>)

Convert and encode the given values to payloads.

public static Task<IReadOnlyCollection<Payload>> ToPayloadsAsync(this DataConverter converter, IReadOnlyCollection<object?> values)

Parameters

converter DataConverter

Converter to use.

values IReadOnlyCollection<object>

Values to convert and encode.

Returns

Task<IReadOnlyCollection<Payload>>

Converted and encoded payloads.

ToRawValue(IPayloadConverter, object?)

Convert the given value to a raw value.

public static RawValue ToRawValue(this IPayloadConverter converter, object? value)

Parameters

converter IPayloadConverter

The converter to use.

value object

The value to convert.

Returns

RawValue

The converted value.

ToSingleValueAsync(DataConverter, IReadOnlyCollection<Payload>, Type)

Decode and convert the given payloads to a single value.

public static Task<object?> ToSingleValueAsync(this DataConverter converter, IReadOnlyCollection<Payload> payloads, Type type)

Parameters

converter DataConverter

Converter to use.

payloads IReadOnlyCollection<Payload>

Payloads to decode and convert.

type Type

Type to convert to.

Returns

Task<object>

Decoded and converted value.

Exceptions

ArgumentException

If there is not exactly one value.

ToSingleValueAsync<T>(DataConverter, IReadOnlyCollection<Payload>)

Decode and convert the given payloads to a single value.

public static Task<T> ToSingleValueAsync<T>(this DataConverter converter, IReadOnlyCollection<Payload> payloads)

Parameters

converter DataConverter

Converter to use.

payloads IReadOnlyCollection<Payload>

Payloads to decode and convert.

Returns

Task<T>

Decoded and converted value.

Type Parameters

T

Type to convert to.

Exceptions

ArgumentException

If there is not exactly one value.

ToValueAsync(DataConverter, Payload, Type)

Decode and convert the given payload to a value of the given type.

public static Task<object?> ToValueAsync(this DataConverter converter, Payload payload, Type type)

Parameters

converter DataConverter

The converter to use.

payload Payload

The payload to convert.

type Type

Type to convert to.

Returns

Task<object>

Decoded and converted value.

Remarks

Usually ToSingleValueAsync(DataConverter, IReadOnlyCollection<Payload>, Type) is better because an encoder could have encoded into multiple payloads. However for some maps like memos and headers, there may only be a single payload to decode.

ToValueAsync<T>(DataConverter, Payload)

Decode and convert the given payload to a value of the given type.

public static Task<T> ToValueAsync<T>(this DataConverter converter, Payload payload)

Parameters

converter DataConverter

The converter to use.

payload Payload

The payload to convert.

Returns

Task<T>

Decoded and converted value.

Type Parameters

T

Value type.

Remarks

Usually ToSingleValueAsync(DataConverter, IReadOnlyCollection<Payload>, Type) is better because an encoder could have encoded into multiple payloads. However for some maps like memos and headers, there may only be a single payload to decode.

ToValue<T>(IPayloadConverter, Payload)

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

public static T ToValue<T>(this IPayloadConverter converter, Payload payload)

Parameters

converter IPayloadConverter

The converter to use.

payload Payload

The payload to convert.

Returns

T

The converted value.

Type Parameters

T

Value type.

ToValue<T>(IPayloadConverter, IRawValue)

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

public static T ToValue<T>(this IPayloadConverter converter, IRawValue rawValue)

Parameters

converter IPayloadConverter

The converter to use.

rawValue IRawValue

The raw value to convert.

Returns

T

The converted value.

Type Parameters

T

Value type.