elsa-core/src/runtime/Elsa.Runtime.ProtoActor/Extensions/ProtoInputExtensions.cs
Sipke Schoorstra 261c9cb1a5
Implement Default Workflow Invoker (#2979)
* Implement default invoker

* Proto actor improvements

* Refactor workflow registry handling

* Update migrations
2022-04-30 11:10:08 +02:00

27 lines
727 B
C#

using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Elsa.Runtime.Protos;
namespace Elsa.Runtime.ProtoActor.Extensions;
public static class ProtoInputExtensions
{
public static IDictionary<string, object> Deserialize(this Input input) => input.Data.ToDictionary(x => x.Key, x => JsonSerializer.Deserialize<object>(x.Value.Text)!);
public static Input Serialize(this IDictionary<string, object> input)
{
var result = new Input();
var data = result.Data;
foreach (var (key, value) in input)
{
data[key] = new Json
{
Text = JsonSerializer.Serialize(value)
};
}
return result;
}
}