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
converterDataConverterConverter to use.
failureFailureFailure 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
converterDataConverterConverter to use.
excExceptionException 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
converterDataConverterConverter to use.
valueobjectValue 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
converterIPayloadConverterConverter to use.
valuesIReadOnlyCollection<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
converterDataConverterConverter to use.
valuesIReadOnlyCollection<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
converterIPayloadConverterThe converter to use.
valueobjectThe 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
converterDataConverterConverter to use.
payloadsIReadOnlyCollection<Payload>Payloads to decode and convert.
typeTypeType 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
converterDataConverterConverter to use.
payloadsIReadOnlyCollection<Payload>Payloads to decode and convert.
Returns
- Task<T>
Decoded and converted value.
Type Parameters
TType 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
converterDataConverterThe converter to use.
payloadPayloadThe payload to convert.
typeTypeType 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
converterDataConverterThe converter to use.
payloadPayloadThe payload to convert.
Returns
- Task<T>
Decoded and converted value.
Type Parameters
TValue 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
converterIPayloadConverterThe converter to use.
payloadPayloadThe payload to convert.
Returns
- T
The converted value.
Type Parameters
TValue 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
converterIPayloadConverterThe converter to use.
rawValueIRawValueThe raw value to convert.
Returns
- T
The converted value.
Type Parameters
TValue type.