Fix dynamic deserilization in proto actor (#4168)

This commit is contained in:
gurkanguran 2023-06-28 18:15:32 +02:00 committed by GitHub
parent e0dd53b1ad
commit ad72e99c62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -30,6 +30,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />
</ItemGroup>

View file

@ -1,11 +1,20 @@
using System.Dynamic;
using System.Text.Json;
using System.Text.Json.Nodes;
using Elsa.ProtoActor.Protos;
using Elsa.Workflows.Core.Serialization.Converters;
namespace Elsa.ProtoActor.Extensions;
internal 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 IDictionary<string, object> Deserialize(this Input input)
{
var jsonSerializerOptions = new JsonSerializerOptions();
jsonSerializerOptions.Converters.Add(new ExpandoObjectConverterFactory());
return input.Data.ToDictionary(x => x.Key, x => JsonSerializer.Deserialize<object>(x.Value.Text, jsonSerializerOptions)!);
}
public static Input Serialize(this IDictionary<string, object> input)
{