@@ -100,7 +100,7 @@ protected virtual TaskIdentity GetNextTask(Map<string, TaskDefinition> tasksList
100100 {
101101 ArgumentNullException . ThrowIfNull ( tasksList ) ;
102102 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 ;
104104 if ( transition == FlowDirective . End || transition == FlowDirective . Exit )
105105 {
106106 return new TaskIdentity ( transition , - 1 , null ) ;
@@ -122,11 +122,8 @@ protected virtual TaskIdentity GetNextTask(Map<string, TaskDefinition> tasksList
122122 {
123123 index = 0 ;
124124 }
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 ) ;
130127 }
131128
132129 /// <summary>
@@ -138,43 +135,43 @@ protected virtual void BuildTransitions(INodeViewModel node, TaskNodeRenderingCo
138135 {
139136 ArgumentNullException . ThrowIfNull ( node ) ;
140137 ArgumentNullException . ThrowIfNull ( context ) ;
141- this . Logger . LogTrace ( $ "Starting WorkflowGraphBuilder.BuildTransitions from '{ node . Id } '") ;
138+ this . Logger . LogTrace ( "Starting WorkflowGraphBuilder.BuildTransitions from '{nodeId }'" , node . Id ) ;
142139 List < TaskIdentity > transitions = [ ] ;
143140 TaskIdentity nextTask = this . GetNextTask ( context . TasksList , context . TaskName ) ;
144141 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 ) ;
146143 while ( ! string . IsNullOrWhiteSpace ( nextTask ? . Definition ? . If ) )
147144 {
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 ) ;
149146 nextTask = this . GetNextTask ( context . TasksList , nextTask . Name ) ;
150147 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 ) ;
152149 }
153150 foreach ( var transition in transitions . Distinct ( new TaskIdentityComparer ( ) ) )
154151 {
155152 if ( transition . Index != - 1 )
156153 {
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 ) ;
158155 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 ) ;
160157 this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , GetNodeAnchor ( transitionNode , NodePortType . Entry ) ) ;
161158 }
162- else if ( transition . Name == FlowDirective . Exit )
159+ else if ( transition . Name == FlowDirective . Exit )
163160 {
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 ) ;
165162 this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , context . ExitNode ) ;
166163 }
167164 else if ( transition . Name == FlowDirective . End )
168165 {
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 ) ;
170167 this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , context . Graph . AllNodes . Skip ( 1 ) . First ( ) . Value ) ;
171168 }
172169 else
173170 {
174171 throw new IndexOutOfRangeException ( "Invalid transition" ) ;
175172 }
176173 }
177- this . Logger . LogTrace ( $ "Exiting WorkflowGraphBuilder.BuildTransitions from '{ node . Id } '") ;
174+ this . Logger . LogTrace ( "Exiting WorkflowGraphBuilder.BuildTransitions from '{nodeId }'" , node . Id ) ;
178175 }
179176
180177 /// <summary>
@@ -191,15 +188,15 @@ protected virtual void BuildTransitions(INodeViewModel node, TaskNodeRenderingCo
191188 protected INodeViewModel BuildTaskNode ( TaskNodeRenderingContext context )
192189 {
193190 ArgumentNullException . ThrowIfNull ( context ) ;
194- this . Logger . LogTrace ( $ "Starting WorkflowGraphBuilder.BuildTaskNode for { context . TaskName } " ) ;
191+ this . Logger . LogTrace ( "Starting WorkflowGraphBuilder.BuildTaskNode for '{contextTaskName}'" , context . TaskName ) ;
195192 if ( context . Graph . AllNodes . ContainsKey ( context . TaskReference ) )
196193 {
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 ) ;
198195 return context . Graph . AllNodes [ context . TaskReference ] ;
199196 }
200197 if ( context . Graph . AllClusters . ContainsKey ( context . TaskReference ) )
201198 {
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 ) ;
203200 return context . Graph . AllClusters [ context . TaskReference ] ;
204201 }
205202 return context . TaskDefinition switch
@@ -360,7 +357,7 @@ protected virtual NodeViewModel BuildForkTaskNode(TaskNodeRenderingContext<ForkT
360357 cluster . AddChild ( exitPort ) ;
361358 if ( context . TaskGroup == null ) context . Graph . AddCluster ( cluster ) ;
362359 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 ++ )
364361 {
365362 var branch = context . TaskDefinition . Fork . Branches . ElementAt ( i ) ;
366363 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
485482 foreach ( var switchCase in context . TaskDefinition . Switch )
486483 {
487484 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 ) ) ;
489486 this . BuildEdge ( context . Graph , this . GetNodeAnchor ( node , NodePortType . Exit ) , GetNodeAnchor ( switchCaseNode , NodePortType . Entry ) ) ;
490487 }
491488 if ( ! context . TaskDefinition . Switch . Any ( switchCase => string . IsNullOrEmpty ( switchCase . Value . When ) ) )
@@ -532,7 +529,7 @@ protected virtual NodeViewModel BuildTryTaskNode(TaskNodeRenderingContext<TryTas
532529 }
533530 else
534531 {
535- var catchCluster = new CatchDoNodeViewModel ( context . TaskReference + _catchSuffix , context . TaskName , catchContent ) ;
532+ var catchCluster = new CatchDoNodeViewModel ( context . TaskReference + _catchSuffix , context . TaskName ! , catchContent ) ;
536533 var catchEntryPort = new PortNodeViewModel ( context . TaskReference + _catchSuffix + _clusterEntrySuffix ) ;
537534 var catchExitPort = new PortNodeViewModel ( context . TaskReference + _catchSuffix + _clusterExitSuffix ) ;
538535 catchCluster . AddChild ( catchEntryPort ) ;
@@ -581,7 +578,8 @@ protected virtual IEdgeViewModel BuildEdge(IGraphViewModel graph, INodeViewModel
581578 var edge = graph . Edges . Select ( keyValuePair => keyValuePair . Value ) . FirstOrDefault ( edge => edge . SourceId == source . Id && edge . TargetId == target . Id ) ;
582579 if ( edge != null )
583580 {
584- if ( ! string . IsNullOrEmpty ( label ) ) {
581+ if ( ! string . IsNullOrEmpty ( label ) )
582+ {
585583 edge . Label = edge . Label + " / " + label ;
586584 edge . Width = edge . Label . Length * characterSize ;
587585 }
@@ -752,7 +750,7 @@ public bool Equals(TaskIdentity? identity1, TaskIdentity? identity2)
752750 if ( identity1 is null || identity2 is null )
753751 return false ;
754752
755- return identity1 . Name == identity2 . Name &&
753+ return identity1 . Name == identity2 . Name &&
756754 identity1 . Index == identity2 . Index &&
757755 identity1 . Definition == identity2 . Definition ;
758756 }
0 commit comments