@@ -9,12 +9,16 @@ namespace WorkflowCore.Persistence.EntityFramework
99{
1010 internal static class ExtensionMethods
1111 {
12- private static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling . All } ;
12+ private static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
13+ {
14+ TypeNameHandling = TypeNameHandling . All ,
15+ ObjectCreationHandling = ObjectCreationHandling . Replace
16+ } ;
1317
1418 internal static PersistedWorkflow ToPersistable ( this WorkflowInstance instance , PersistedWorkflow persistable = null )
1519 {
16- if ( persistable == null )
17- persistable = new PersistedWorkflow ( ) ;
20+ if ( persistable == null )
21+ persistable = new PersistedWorkflow ( ) ;
1822
1923 persistable . Data = JsonConvert . SerializeObject ( instance . Data , SerializerSettings ) ;
2024 persistable . Description = instance . Description ;
@@ -25,19 +29,19 @@ internal static PersistedWorkflow ToPersistable(this WorkflowInstance instance,
2529 persistable . WorkflowDefinitionId = instance . WorkflowDefinitionId ;
2630 persistable . Status = instance . Status ;
2731 persistable . CreateTime = instance . CreateTime ;
28- persistable . CompleteTime = instance . CompleteTime ;
29-
32+ persistable . CompleteTime = instance . CompleteTime ;
33+
3034 foreach ( var ep in instance . ExecutionPointers )
3135 {
3236 var persistedEP = persistable . ExecutionPointers . FindById ( ep . Id ) ;
33-
37+
3438 if ( persistedEP == null )
3539 {
3640 persistedEP = new PersistedExecutionPointer ( ) ;
3741 persistedEP . Id = ep . Id ?? Guid . NewGuid ( ) . ToString ( ) ;
3842 persistable . ExecutionPointers . Add ( persistedEP ) ;
39- }
40-
43+ }
44+
4145 persistedEP . StepId = ep . StepId ;
4246 persistedEP . Active = ep . Active ;
4347 persistedEP . SleepUntil = ep . SleepUntil ;
@@ -83,7 +87,7 @@ internal static PersistedWorkflow ToPersistable(this WorkflowInstance instance,
8387
8488 internal static PersistedExecutionError ToPersistable ( this ExecutionError instance )
8589 {
86- var result = new PersistedExecutionError ( ) ;
90+ var result = new PersistedExecutionError ( ) ;
8791 result . ErrorTime = instance . ErrorTime ;
8892 result . Message = instance . Message ;
8993 result . ExecutionPointerId = instance . ExecutionPointerId ;
@@ -94,7 +98,7 @@ internal static PersistedExecutionError ToPersistable(this ExecutionError instan
9498
9599 internal static PersistedSubscription ToPersistable ( this EventSubscription instance )
96100 {
97- PersistedSubscription result = new PersistedSubscription ( ) ;
101+ PersistedSubscription result = new PersistedSubscription ( ) ;
98102 result . SubscriptionId = new Guid ( instance . Id ) ;
99103 result . EventKey = instance . EventKey ;
100104 result . EventName = instance . EventName ;
@@ -106,7 +110,7 @@ internal static PersistedSubscription ToPersistable(this EventSubscription insta
106110 result . ExternalToken = instance . ExternalToken ;
107111 result . ExternalTokenExpiry = instance . ExternalTokenExpiry ;
108112 result . ExternalWorkerId = instance . ExternalWorkerId ;
109-
113+
110114 return result ;
111115 }
112116
@@ -152,7 +156,7 @@ internal static WorkflowInstance ToWorkflowInstance(this PersistedWorkflow insta
152156
153157 foreach ( var ep in instance . ExecutionPointers )
154158 {
155- var pointer = new ExecutionPointer ( ) ;
159+ var pointer = new ExecutionPointer ( ) ;
156160
157161 pointer . Id = ep . Id ;
158162 pointer . StepId = ep . StepId ;
0 commit comments