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
DataConverterConverter to use.
failure
FailureFailure to decode and convert. This may be mutated.
Returns
ToFailureAsync(DataConverter, Exception)
Convert and encode the given exception to failure.
public static Task<Failure> ToFailureAsync(this DataConverter converter, Exception exc)
Parameters
converter
DataConverterConverter to use.
exc
ExceptionException convert and encode.
Returns
ToPayloadAsync(DataConverter, object?)
Convert and encode the given value to a payload.
public static Task<Payload> ToPayloadAsync(this DataConverter converter, object? value)
Parameters
converter
DataConverterConverter to use.
value
objectValue to convert and encode.
Returns
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
IPayloadConverterConverter 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
DataConverterConverter 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
IPayloadConverterThe converter to use.
value
objectThe 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
DataConverterConverter to use.
payloads
IReadOnlyCollection<Payload>Payloads to decode and convert.
type
TypeType to convert to.
Returns
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
DataConverterConverter 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
DataConverterThe converter to use.
payload
PayloadThe payload to convert.
type
TypeType to convert to.
Returns
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
DataConverterThe converter to use.
payload
PayloadThe 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
IPayloadConverterThe converter to use.
payload
PayloadThe 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
IPayloadConverterThe converter to use.
rawValue
IRawValueThe raw value to convert.
Returns
- T
The converted value.
Type Parameters
T
Value type.