11
11
using WorkflowCore . Primitives ;
12
12
using WorkflowCore . Models . DefinitionStorage ;
13
13
using WorkflowCore . Models . DefinitionStorage . v1 ;
14
+ using WorkflowCore . Exceptions ;
14
15
15
16
namespace WorkflowCore . Services . DefinitionStorage
16
17
{
@@ -22,7 +23,7 @@ public DefinitionLoader(IWorkflowRegistry registry)
22
23
{
23
24
_registry = registry ;
24
25
}
25
-
26
+
26
27
public WorkflowDefinition LoadDefinition ( string json )
27
28
{
28
29
var source = JsonConvert . DeserializeObject < DefinitionSourceV1 > ( json ) ;
@@ -107,8 +108,14 @@ private List<WorkflowStep> ConvertSteps(ICollection<StepSourceV1> source, Type d
107
108
108
109
foreach ( var step in result )
109
110
{
111
+ if ( result . Any ( x => x . Tag == step . Tag && x . Id != step . Id ) )
112
+ throw new WorkflowDefinitionLoadException ( $ "Duplicate step Id { step . Tag } ") ;
113
+
110
114
foreach ( var outcome in step . Outcomes )
111
115
{
116
+ if ( result . All ( x => x . Tag != outcome . Tag ) )
117
+ throw new WorkflowDefinitionLoadException ( $ "Cannot find step id { outcome . Tag } ") ;
118
+
112
119
outcome . NextStep = result . Single ( x => x . Tag == outcome . Tag ) . Id ;
113
120
}
114
121
}
@@ -137,8 +144,6 @@ private void AttachInputs(StepSourceV1 source, Type dataType, Type stepType, Wor
137
144
{
138
145
var dataParameter = Expression . Parameter ( dataType , "data" ) ;
139
146
var contextParameter = Expression . Parameter ( typeof ( IStepExecutionContext ) , "context" ) ;
140
-
141
- // https://github.com/StefH/System.Linq.Dynamic.Core/wiki/Dynamic-Expressions
142
147
var sourceExpr = DynamicExpressionParser . ParseLambda ( new [ ] { dataParameter , contextParameter } , typeof ( object ) , input . Value ) ;
143
148
var targetExpr = Expression . Property ( Expression . Parameter ( stepType ) , input . Key ) ;
144
149
@@ -168,7 +173,7 @@ private void AttachOutputs(StepSourceV1 source, Type dataType, Type stepType, Wo
168
173
169
174
private Type FindType ( string name )
170
175
{
171
- return Type . GetType ( name ) ;
176
+ return Type . GetType ( name , true , true ) ;
172
177
}
173
178
174
179
}
0 commit comments