Update input JSON converter to also read its ID
This commit is contained in:
parent
876816b84c
commit
cdef7d409d
|
|
@ -39,7 +39,7 @@ public class InputJsonConverter<T> : JsonConverter<Input<T>>
|
|||
|
||||
if (!expressionElement.TryGetProperty("type", out var expressionTypeNameElement))
|
||||
return default!;
|
||||
|
||||
|
||||
if (!expressionElement.TryGetProperty("value", out _))
|
||||
return default!;
|
||||
|
||||
|
|
@ -49,10 +49,21 @@ public class InputJsonConverter<T> : JsonConverter<Input<T>>
|
|||
if (expressionSyntaxDescriptor == null)
|
||||
return default!;
|
||||
|
||||
doc.RootElement.TryGetProperty("memoryReference", out var memoryReferenceElement);
|
||||
|
||||
var memoryReferenceId = memoryReferenceElement.ValueKind == JsonValueKind.Undefined
|
||||
? default
|
||||
: memoryReferenceElement.TryGetProperty("id", out var memoryReferenceIdElement)
|
||||
? memoryReferenceIdElement.GetString()
|
||||
: default;
|
||||
|
||||
var context = new ExpressionConstructorContext(expressionElement, options);
|
||||
var expression = expressionSyntaxDescriptor.CreateExpression(context);
|
||||
var memoryBlockReference = expressionSyntaxDescriptor.CreateBlockReference(new BlockReferenceConstructorContext(expression));
|
||||
|
||||
if (memoryBlockReference.Id == null!)
|
||||
memoryBlockReference.Id = memoryReferenceId!;
|
||||
|
||||
return (Input<T>)Activator.CreateInstance(typeof(Input<T>), expression, memoryBlockReference)!;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"id": "HelloWorld-v1",
|
||||
"definitionId": "11e2b350dae8485498c16d1ce3843829",
|
||||
"name": "Hello World",
|
||||
"root": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using Elsa.Extensions;
|
||||
using Elsa.Testing.Shared;
|
||||
using Elsa.Workflows.Core.Activities;
|
||||
using Elsa.Workflows.Core.Contracts;
|
||||
using Elsa.Workflows.Core.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
|
|||
Loading…
Reference in a new issue