private void Next(object sender, MacroCommandIsDoneEventArgs e) { var previousCommand = sender as IWaitableCommand; if (previousCommand != null) { previousCommand.IsDone -= Next; } if (e.ResponseStatus == ResponseStatus.Cancel || e.ResponseStatus == ResponseStatus.Error) { InvokeAllDone(false); return; } _runIndex++; if (e.ResponseStatus == ResponseStatus.Skip) { Next(sender, new MacroCommandIsDoneEventArgs(ResponseStatus.Success)); } if (CommandList.Count > _runIndex) { var command = CommandList.ElementAt(_runIndex); var macroCommand = command as IWaitableCommand; if (macroCommand != null) { macroCommand.IsDone += Next; macroCommand.Execute(_parameter); } else { command.Execute(_parameter); Next(command, new MacroCommandIsDoneEventArgs(ResponseStatus.Success)); } } else { InvokeAllDone(true); } }
private void Next(object sender, MacroCommandIsDoneEventArgs e) { if (sender is IWaitableCommand previousCommand) { previousCommand.IsDone -= Next; } if (e.ResponseStatus == ResponseStatus.Cancel || e.ResponseStatus == ResponseStatus.Error) { InvokeAllDone(false); return; } _runIndex++; if (e.ResponseStatus == ResponseStatus.Skip) { Next(sender, new MacroCommandIsDoneEventArgs(ResponseStatus.Success)); } if (CommandList.Count > _runIndex) { var command = CommandList.ElementAt(_runIndex); switch (command) { case IWaitableCommand waitableCommand: waitableCommand.IsDone += Next; waitableCommand.Execute(_parameter); break; default: command.Execute(_parameter); Next(command, new MacroCommandIsDoneEventArgs(ResponseStatus.Success)); break; } } else { InvokeAllDone(true); } }