-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathIPayloadConverter.cs
39 lines (37 loc) · 1.41 KB
/
IPayloadConverter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using Temporalio.Api.Common.V1;
namespace Temporalio.Converters
{
/// <summary>
/// Representation of a converter from a value to/from a payload.
/// </summary>
/// <remarks>
/// This converter should be deterministic since it is used for workflows. For the same reason,
/// this converter should be immediate and avoid any network calls or any asynchronous/slow code
/// paths.
/// </remarks>
/// <seealso cref="DefaultPayloadConverter" />
public interface IPayloadConverter
{
/// <summary>
/// Convert the given value to a payload.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>The converted payload.</returns>
/// <remarks>
/// Implementers are expected to be able just return the payload for
/// <see cref="IRawValue" />.
/// </remarks>
Payload ToPayload(object? value);
/// <summary>
/// Convert the given payload to a value of the given type.
/// </summary>
/// <param name="payload">The payload to convert.</param>
/// <param name="type">The type to convert to.</param>
/// <returns>The converted value.</returns>
/// <remarks>
/// Implementers are expected to be able to support types of <see cref="IRawValue" />.
/// </remarks>
object? ToValue(Payload payload, Type type);
}
}