@@ -100,7 +100,7 @@ protected virtual TaskIdentity GetNextTask(Map<string, TaskDefinition> tasksList
100
100
{
101
101
ArgumentNullException . ThrowIfNull ( tasksList ) ;
102
102
var taskDefinition = tasksList . FirstOrDefault ( taskEntry => taskEntry . Key == currentTask ) ? . Value ;
103
- transition = ! string . IsNullOrWhiteSpace ( transition ) ? transition : taskDefinition != null ? taskDefinition . Then : null ;
103
+ transition = ! string . IsNullOrWhiteSpace ( transition ) ? transition : taskDefinition ? . Then ;
104
104
if ( transition == FlowDirective . End || transition == FlowDirective . Exit )
105
105
{
106
106
return new TaskIdentity ( transition , - 1 , null ) ;
@@ -122,11 +122,8 @@ protected virtual TaskIdentity GetNextTask(Map<string, TaskDefinition> tasksList
122
122
{
123
123
index = 0 ;
124
124
}
125
- if ( context . Graph . AllNodes . ContainsKey ( reference ) )
126
- {
127
- return ( NodeViewModel ) context . Graph . AllNodes [ reference ] ;
128
- }
129
- throw new IndexOutOfRangeException ( $ "Unable to find the task with reference '{ reference } ' in the provided context.") ;
125
+ var taskEntry = tasksList . ElementAt ( index ) ;
126
+ return new TaskIdentity ( taskEntry . Key , index , taskEntry . Value ) ;
130
127
}
131
128
132
129
/// <summary>
@@ -138,43 +135,43 @@ protected virtual void BuildTransitions(INodeViewModel node, TaskNodeRenderingCo
138
135
{
139
136
ArgumentNullException . ThrowIfNull ( node ) ;
140
137
ArgumentNullException . ThrowIfNull ( context ) ;
141
- this . Logger . LogTrace ( $ "Starting WorkflowGraphBuilder.BuildTransitions from '{ node . Id } '") ;
138
+ this . Logger . LogTrace ( "Starting WorkflowGraphBuilder.BuildTransitions from '{nodeId }'" , node . Id ) ;
142
139
List < TaskIdentity > transitions = [ ] ;
143
140
TaskIdentity nextTask = this . GetNextTask ( context . TasksList , context . TaskName ) ;
144
141
transitions . Add ( nextTask ) ;
145
- this . Logger . LogTrace ( $ "[WorkflowGraphBuilder.BuildTransitions][{ node . Id } ] found transition to '{ nextTask ? . Name } '" ) ;
142
+ this . Logger . LogTrace ( "[WorkflowGraphBuilder.BuildTransitions][{nodeId }] found transition to '{nextTaskName}'" , node . Id , nextTask ? . Name ) ;
146
143
while ( ! string . IsNullOrWhiteSpace ( nextTask ? . Definition ? . If ) )
147
144
{
148
- this . Logger . LogTrace ( $ "[WorkflowGraphBuilder.BuildTransitions][{ node . Id } ] if clause found, looking up next task.") ;
145
+ this . Logger . LogTrace ( "[WorkflowGraphBuilder.BuildTransitions][{nodeId }] if clause found, looking up next task." , node . Id ) ;
149
146
nextTask = this . GetNextTask ( context . TasksList , nextTask . Name ) ;
150
147
transitions . Add ( nextTask ) ;
151
- this . Logger . LogTrace ( $ "[WorkflowGraphBuilder.BuildTransitions][{ node . Id } ] found transition to '{ nextTask ? . Name } '" ) ;
148
+ this . Logger . LogTrace ( "[WorkflowGraphBuilder.BuildTransitions][{nodeId }] found transition to '{nextTaskName}'" , node . Id , nextTask ? . Name ) ;
152
149
}
153
150
foreach ( var transition in transitions . Distinct ( new TaskIdentityComparer ( ) ) )
154
151
{
155
152
if ( transition . Index != - 1 )
156
153
{
157
- this . Logger . LogTrace ( $ "[WorkflowGraphBuilder.BuildTransitions][{ node . Id } ] Building node '{ transition . Name } '") ;
154
+ this . Logger . LogTrace ( "[WorkflowGraphBuilder.BuildTransitions][{nodeId }] Building node '{transitionName }'" , node . Id , transition . Name ) ;
158
155
var transitionNode = this . BuildTaskNode ( new ( context . Workflow , context . Graph , context . TasksList , transition . Index , transition . Name , transition . Definition , context . TaskGroup , context . ParentReference , context . ParentContext , context . EntryNode , context . ExitNode ) ) ;
159
- this . Logger . LogTrace ( $ "[WorkflowGraphBuilder.BuildTransitions][{ node . Id } ] Building edge to node '{ transition . Name } '") ;
156
+ this . Logger . LogTrace ( "[WorkflowGraphBuilder.BuildTransitions][{nodeId }] Building edge to node '{transitionName }'" , node . Id , transition . Name ) ;
160
157
this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , GetNodeAnchor ( transitionNode , NodePortType . Entry ) ) ;
161
158
}
162
- else if ( transition . Name == FlowDirective . Exit )
159
+ else if ( transition . Name == FlowDirective . Exit )
163
160
{
164
- this . Logger . LogTrace ( $ "[WorkflowGraphBuilder.BuildTransitions][{ node . Id } ] Exit transition, building edge to node '{ context . ExitNode } '") ;
161
+ this . Logger . LogTrace ( "[WorkflowGraphBuilder.BuildTransitions][{nodeId }] Exit transition, building edge to node '{contextExitNode }'" , node . Id , context . ExitNode ) ;
165
162
this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , context . ExitNode ) ;
166
163
}
167
164
else if ( transition . Name == FlowDirective . End )
168
165
{
169
- this . Logger . LogTrace ( $ "[WorkflowGraphBuilder.BuildTransitions][{ node . Id } ] End transition, building edge to node '{ context . ExitNode } '") ;
166
+ this . Logger . LogTrace ( "[WorkflowGraphBuilder.BuildTransitions][{nodeId }] End transition, building edge to node '{contextExitNode }'" , node . Id , context . ExitNode ) ;
170
167
this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , context . Graph . AllNodes . Skip ( 1 ) . First ( ) . Value ) ;
171
168
}
172
169
else
173
170
{
174
171
throw new IndexOutOfRangeException ( "Invalid transition" ) ;
175
172
}
176
173
}
177
- this . Logger . LogTrace ( $ "Exiting WorkflowGraphBuilder.BuildTransitions from '{ node . Id } '") ;
174
+ this . Logger . LogTrace ( "Exiting WorkflowGraphBuilder.BuildTransitions from '{nodeId }'" , node . Id ) ;
178
175
}
179
176
180
177
/// <summary>
@@ -191,15 +188,15 @@ protected virtual void BuildTransitions(INodeViewModel node, TaskNodeRenderingCo
191
188
protected INodeViewModel BuildTaskNode ( TaskNodeRenderingContext context )
192
189
{
193
190
ArgumentNullException . ThrowIfNull ( context ) ;
194
- this . Logger . LogTrace ( $ "Starting WorkflowGraphBuilder.BuildTaskNode for { context . TaskName } " ) ;
191
+ this . Logger . LogTrace ( "Starting WorkflowGraphBuilder.BuildTaskNode for '{contextTaskName}'" , context . TaskName ) ;
195
192
if ( context . Graph . AllNodes . ContainsKey ( context . TaskReference ) )
196
193
{
197
- this . Logger . LogTrace ( $ "Exiting WorkflowGraphBuilder.BuildTaskNode for { context . TaskName } , found existing node.") ;
194
+ this . Logger . LogTrace ( "Exiting WorkflowGraphBuilder.BuildTaskNode for '{contextTaskName}' , found existing node." , context . TaskName ) ;
198
195
return context . Graph . AllNodes [ context . TaskReference ] ;
199
196
}
200
197
if ( context . Graph . AllClusters . ContainsKey ( context . TaskReference ) )
201
198
{
202
- this . Logger . LogTrace ( $ "Exiting WorkflowGraphBuilder.BuildTaskNode for { context . TaskName } , found existing cluster.") ;
199
+ this . Logger . LogTrace ( "Exiting WorkflowGraphBuilder.BuildTaskNode for '{contextTaskName}' , found existing cluster." , context . TaskName ) ;
203
200
return context . Graph . AllClusters [ context . TaskReference ] ;
204
201
}
205
202
return context . TaskDefinition switch
@@ -360,7 +357,7 @@ protected virtual NodeViewModel BuildForkTaskNode(TaskNodeRenderingContext<ForkT
360
357
cluster . AddChild ( exitPort ) ;
361
358
if ( context . TaskGroup == null ) context . Graph . AddCluster ( cluster ) ;
362
359
else context . TaskGroup . AddChild ( cluster ) ;
363
- for ( int i = 0 , c = context . TaskDefinition . Fork . Branches . Count ; i < c ; i ++ )
360
+ for ( int i = 0 , c = context . TaskDefinition . Fork . Branches . Count ; i < c ; i ++ )
364
361
{
365
362
var branch = context . TaskDefinition . Fork . Branches . ElementAt ( i ) ;
366
363
var branchNode = this . BuildTaskNode ( new ( context . Workflow , context . Graph , [ ] , i , branch . Key , branch . Value , cluster , context . TaskReference + "/fork/branches" , context , entryPort , exitPort ) ) ;
@@ -485,7 +482,7 @@ protected virtual NodeViewModel BuildSwitchTaskNode(TaskNodeRenderingContext<Swi
485
482
foreach ( var switchCase in context . TaskDefinition . Switch )
486
483
{
487
484
var switchCaseTask = this . GetNextTask ( context . TasksList , context . TaskName , switchCase . Value . Then ) ! ;
488
- var switchCaseNode = this . BuildTaskNode ( new ( context . Workflow , context . Graph , context . TasksList , switchCaseTask . Index , switchCaseTask . Name , switchCaseTask . Definition , context . TaskGroup , context . ParentReference , context . ParentContext , context . EntryNode , context . ExitNode ) ) ;
485
+ var switchCaseNode = this . BuildTaskNode ( new ( context . Workflow , context . Graph , context . TasksList , switchCaseTask . Index , switchCaseTask . Name , switchCaseTask . Definition , context . TaskGroup , context . ParentReference , context . ParentContext , context . EntryNode , context . ExitNode ) ) ;
489
486
this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , GetNodeAnchor ( switchCaseNode , NodePortType . Entry ) ) ;
490
487
}
491
488
if ( ! context . TaskDefinition . Switch . Any ( switchCase => string . IsNullOrEmpty ( switchCase . Value . When ) ) )
@@ -532,7 +529,7 @@ protected virtual NodeViewModel BuildTryTaskNode(TaskNodeRenderingContext<TryTas
532
529
}
533
530
else
534
531
{
535
- var catchCluster = new CatchDoNodeViewModel ( context . TaskReference + _catchSuffix , context . TaskName , catchContent ) ;
532
+ var catchCluster = new CatchDoNodeViewModel ( context . TaskReference + _catchSuffix , context . TaskName ! , catchContent ) ;
536
533
var catchEntryPort = new PortNodeViewModel ( context . TaskReference + _catchSuffix + _clusterEntrySuffix ) ;
537
534
var catchExitPort = new PortNodeViewModel ( context . TaskReference + _catchSuffix + _clusterExitSuffix ) ;
538
535
catchCluster . AddChild ( catchEntryPort ) ;
@@ -581,7 +578,8 @@ protected virtual IEdgeViewModel BuildEdge(IGraphViewModel graph, INodeViewModel
581
578
var edge = graph . Edges . Select ( keyValuePair => keyValuePair . Value ) . FirstOrDefault ( edge => edge . SourceId == source . Id && edge . TargetId == target . Id ) ;
582
579
if ( edge != null )
583
580
{
584
- if ( ! string . IsNullOrEmpty ( label ) ) {
581
+ if ( ! string . IsNullOrEmpty ( label ) )
582
+ {
585
583
edge . Label = edge . Label + " / " + label ;
586
584
edge . Width = edge . Label . Length * characterSize ;
587
585
}
@@ -752,7 +750,7 @@ public bool Equals(TaskIdentity? identity1, TaskIdentity? identity2)
752
750
if ( identity1 is null || identity2 is null )
753
751
return false ;
754
752
755
- return identity1 . Name == identity2 . Name &&
753
+ return identity1 . Name == identity2 . Name &&
756
754
identity1 . Index == identity2 . Index &&
757
755
identity1 . Definition == identity2 . Definition ;
758
756
}
0 commit comments