Class ConverterExtensions
Extensions for data, payload, and encoding converters.
Namespace: Temporalio.Converters
Assembly: Temporalio.dll
Syntax
public static class ConverterExtensions : object
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.
Declaration
public static Task<Exception> ToExceptionAsync(this DataConverter converter, Failure failure)
Parameters
Type | Name | Description |
---|---|---|
DataConverter | converter | Converter to use. |
Failure | failure | Failure to convert and encode. This may be mutated. |
Returns
Type | Description |
---|---|
Task<Exception> | Decoded and converted exception. |
ToPayloadAsync(DataConverter, Nullable<Object>)
Convert and encode the given value to a payload.
Declaration
public static Task<Payload> ToPayloadAsync(this DataConverter converter, object? value)
Parameters
Type | Name | Description |
---|---|---|
DataConverter | converter | Converter to use. |
Nullable<Object> | value | Value to convert and encode. |
Returns
Type | Description |
---|---|
Task<Payload> | Converted and encoded payload. |
ToPayloadsAsync(DataConverter, IReadOnlyCollection<Nullable<Object>>)
Convert and encode the given values to payloads.
Declaration
public static Task<IEnumerable<Payload>> ToPayloadsAsync(this DataConverter converter, IReadOnlyCollection<object?> values)
Parameters
Type | Name | Description |
---|---|---|
DataConverter | converter | Converter to use. |
IReadOnlyCollection<Nullable<Object>> | values | Values to convert and encode. |
Returns
Type | Description |
---|---|
Task<IEnumerable<Payload>> | Converted and encoded payloads. |
ToSearchAttributesProto(IReadOnlyCollection<KeyValuePair<String, Object>>)
Use the default payload converter to convert attribute values to search attributes.
Declaration
public static SearchAttributes ToSearchAttributesProto(this IReadOnlyCollection<KeyValuePair<string, object>> attrs)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<KeyValuePair<String, Object>> | attrs | Attributes to convert. |
Returns
Type | Description |
---|---|
SearchAttributes | Protobuf search attributes. |
ToSearchAttributeValues(IEnumerable<KeyValuePair<String, Payload>>)
Use the default payload converter to convert payloads to search attribute values.
Declaration
public static IDictionary<string, object> ToSearchAttributeValues(this IEnumerable<KeyValuePair<string, Payload>> payloads)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<String, Payload>> | payloads | Payloads to convert. |
Returns
Type | Description |
---|---|
IDictionary<String, Object> | Converted values. |
ToSearchAttributeValues(SearchAttributes)
Use the default payload converter to convert payloads to search attribute values.
Declaration
public static IDictionary<string, object> ToSearchAttributeValues(this SearchAttributes payloads)
Parameters
Type | Name | Description |
---|---|---|
SearchAttributes | payloads | Payloads to convert. |
Returns
Type | Description |
---|---|
IDictionary<String, Object> | Converted values. |
ToSingleValueAsync<T>(DataConverter, IReadOnlyCollection<Payload>)
Decode and convert the given payloads to a single value.
Declaration
public static Task<T> ToSingleValueAsync<T>(this DataConverter converter, IReadOnlyCollection<Payload> payloads)
Parameters
Type | Name | Description |
---|---|---|
DataConverter | converter | Converter to use. |
IReadOnlyCollection<Payload> | payloads | Payloads to decode and convert. |
Returns
Type | Description |
---|---|
Task<T> | Decoded and converted value. |
Type Parameters
Name | Description |
---|---|
T | Type to convert to. |
ToValue<T>(IPayloadConverter, Payload)
Convert the given payload to a value of the given type.
Declaration
public static T ToValue<T>(this IPayloadConverter converter, Payload payload)
Parameters
Type | Name | Description |
---|---|---|
IPayloadConverter | converter | The converter to use. |
Payload | payload | The payload to convert. |
Returns
Type | Description |
---|---|
T | The converted value. |
Type Parameters
Name | Description |
---|---|
T | Value type. |
ToValueAsync<T>(DataConverter, Payload)
Decode and convert the given payload to a value of the given type.
Declaration
public static Task<T> ToValueAsync<T>(this DataConverter converter, Payload payload)
Parameters
Type | Name | Description |
---|---|---|
DataConverter | converter | The converter to use. |
Payload | payload | The payload to convert. |
Returns
Type | Description |
---|---|
Task<T> | Decoded and converted value. |
Type Parameters
Name | Description |
---|---|
T | Value type. |
Remarks
Usually ToSingleValueAsync<T>(DataConverter, IReadOnlyCollection<Payload>) 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.