File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
SimpleStateMachineNodeEditor/ViewModel/NodesCanvas Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -324,12 +324,35 @@ private void Open()
324324
325325 #region setup start state
326326
327- var startState = stateMachineXElement . Element ( "StartState" ) ? . Attribute ( "Name" ) ? . Value ;
328-
329- if ( string . IsNullOrEmpty ( startState ) )
327+ var startStateElement = stateMachineXElement . Element ( "StartState" ) ;
328+ if ( startStateElement == null )
329+ {
330330 this . SetupStartState ( ) ;
331+ }
331332 else
332- this . SetAsStart ( this . Nodes . Items . Single ( x => x . Name == startState ) ) ;
333+ {
334+ var startStateAttribute = startStateElement . Attribute ( "Name" ) ;
335+ if ( startStateAttribute == null )
336+ {
337+ Error ( "Start state element don't has name attribute" ) ;
338+ return ;
339+ }
340+ else
341+ {
342+ string startStateName = startStateAttribute . Value ;
343+ var startNode = this . Nodes . Items . SingleOrDefault ( x => x . Name == startStateName ) ;
344+ if ( startNode == null )
345+ {
346+ Error ( string . Format ( "Unable to set start state. Node with name \" {0}\" don't exists" , startStateName ) ) ;
347+ return ;
348+ }
349+ else
350+ {
351+ this . SetAsStart ( startNode ) ;
352+ }
353+ }
354+
355+ }
333356
334357 #endregion setup start state
335358
You can’t perform that action at this time.
0 commit comments