public StoryBoardCommandString(StoryBoardCommandString last, string commandStr, int level, out bool failed) { failed = false; if (!IsInvalidCommand(commandStr)) { Level = level; if (last == null) { Parent = null; } else if (last.Parent == null || last.Level == 0) { Parent = last; ParentCommand = last.CurrentCommand; } else if (last.Level < Level) { Parent = last; ParentCommand = last.CurrentCommand; IsFirstSubCommand = true; } else if (last.Level == Level) { Parent = last.Parent; ParentCommand = last.ParentCommand; } else if (last.Level > level) { Parent = last.Parent.Parent; ParentCommand = last.Parent.ParentCommand; } var curTmp = StoryBoardTools.GetEventClassByString(commandStr); if (curTmp != null) { CurrentCommand = curTmp; } else { CurrentCommand = new StoryBoardMainCommand(); } CurrentCommand.Parse(commandStr); if (CurrentCommand is StoryBoardMainCommand mainCommand) { if (mainCommand.Resource is null) { failed = true; } } if (Parent != null) { if (ParentCommand is null) { var tmp = StoryBoardTools.GetEventClassByString(Parent.Command); if (tmp != null) { ParentCommand = tmp; } else { ParentCommand = new StoryBoardMainCommand(); } } ParentCommand.Parse(Parent.Command); if (CurrentCommand is IStoryBoardSubCommand subCmd) { ParentCommand.SubCommands.Add(subCmd); subCmd.ParentCommand = ParentCommand; } } Command = commandStr; } else { failed = true; Command = null; } }