Refactor journal data access and improve byte[] handling (#5878)

Switched to dictionary index access for "ResumeAt" in Delay.cs to ensure more efficient updating. Added handling for byte[] in ObjectConverter.cs to correctly deserialize from base64 strings.
This commit is contained in:
Sipke Schoorstra 2024-08-09 18:20:49 +02:00 committed by GitHub
parent b6acb18dc6
commit ef2dfd3957
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -112,7 +112,13 @@ public static class ObjectConverter
if (underlyingSourceType == typeof(string) && !underlyingTargetType.IsPrimitive && underlyingTargetType != typeof(object))
{
var stringValue = (string)value;
if (underlyingTargetType == typeof(byte[]))
{
// Byte arrays are serialized to base64, so in this case, we convert the string back to the requested target type of byte[].
return Convert.FromBase64String(stringValue);
}
try
{
var firstChar = stringValue.TrimStart().FirstOrDefault();

View file

@ -78,7 +78,7 @@ public class Delay : Activity, IActivityPropertyDefaultValueProvider
var resumeAt = clock.UtcNow.Add(timeSpan);
var payload = new DelayPayload(resumeAt);
context.JournalData.Add("ResumeAt", resumeAt);
context.JournalData["ResumeAt"] = resumeAt;
context.CreateBookmark(payload);
}