@@ -9,12 +9,16 @@ namespace WorkflowCore.Persistence.EntityFramework
9
9
{
10
10
internal static class ExtensionMethods
11
11
{
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
+ } ;
13
17
14
18
internal static PersistedWorkflow ToPersistable ( this WorkflowInstance instance , PersistedWorkflow persistable = null )
15
19
{
16
- if ( persistable == null )
17
- persistable = new PersistedWorkflow ( ) ;
20
+ if ( persistable == null )
21
+ persistable = new PersistedWorkflow ( ) ;
18
22
19
23
persistable . Data = JsonConvert . SerializeObject ( instance . Data , SerializerSettings ) ;
20
24
persistable . Description = instance . Description ;
@@ -25,19 +29,19 @@ internal static PersistedWorkflow ToPersistable(this WorkflowInstance instance,
25
29
persistable . WorkflowDefinitionId = instance . WorkflowDefinitionId ;
26
30
persistable . Status = instance . Status ;
27
31
persistable . CreateTime = instance . CreateTime ;
28
- persistable . CompleteTime = instance . CompleteTime ;
29
-
32
+ persistable . CompleteTime = instance . CompleteTime ;
33
+
30
34
foreach ( var ep in instance . ExecutionPointers )
31
35
{
32
36
var persistedEP = persistable . ExecutionPointers . FindById ( ep . Id ) ;
33
-
37
+
34
38
if ( persistedEP == null )
35
39
{
36
40
persistedEP = new PersistedExecutionPointer ( ) ;
37
41
persistedEP . Id = ep . Id ?? Guid . NewGuid ( ) . ToString ( ) ;
38
42
persistable . ExecutionPointers . Add ( persistedEP ) ;
39
- }
40
-
43
+ }
44
+
41
45
persistedEP . StepId = ep . StepId ;
42
46
persistedEP . Active = ep . Active ;
43
47
persistedEP . SleepUntil = ep . SleepUntil ;
@@ -83,7 +87,7 @@ internal static PersistedWorkflow ToPersistable(this WorkflowInstance instance,
83
87
84
88
internal static PersistedExecutionError ToPersistable ( this ExecutionError instance )
85
89
{
86
- var result = new PersistedExecutionError ( ) ;
90
+ var result = new PersistedExecutionError ( ) ;
87
91
result . ErrorTime = instance . ErrorTime ;
88
92
result . Message = instance . Message ;
89
93
result . ExecutionPointerId = instance . ExecutionPointerId ;
@@ -94,7 +98,7 @@ internal static PersistedExecutionError ToPersistable(this ExecutionError instan
94
98
95
99
internal static PersistedSubscription ToPersistable ( this EventSubscription instance )
96
100
{
97
- PersistedSubscription result = new PersistedSubscription ( ) ;
101
+ PersistedSubscription result = new PersistedSubscription ( ) ;
98
102
result . SubscriptionId = new Guid ( instance . Id ) ;
99
103
result . EventKey = instance . EventKey ;
100
104
result . EventName = instance . EventName ;
@@ -106,7 +110,7 @@ internal static PersistedSubscription ToPersistable(this EventSubscription insta
106
110
result . ExternalToken = instance . ExternalToken ;
107
111
result . ExternalTokenExpiry = instance . ExternalTokenExpiry ;
108
112
result . ExternalWorkerId = instance . ExternalWorkerId ;
109
-
113
+
110
114
return result ;
111
115
}
112
116
@@ -152,7 +156,7 @@ internal static WorkflowInstance ToWorkflowInstance(this PersistedWorkflow insta
152
156
153
157
foreach ( var ep in instance . ExecutionPointers )
154
158
{
155
- var pointer = new ExecutionPointer ( ) ;
159
+ var pointer = new ExecutionPointer ( ) ;
156
160
157
161
pointer . Id = ep . Id ;
158
162
pointer . StepId = ep . StepId ;
0 commit comments