public async Task <ISaga> Handle(ExecuteActionCommand command) { ISaga saga = command.Saga; if (saga == null) { throw new SagaInstanceNotFoundException(command.Model.SagaStateType); } ISagaStep step = command.Model.Actions. FindStepForExecutionStateAndEvent(saga); ISagaAction action = command.Model. FindActionForStep(step); if (step.Async) { saga.ExecutionState.AsyncExecution = AsyncExecution.True(); } ExecuteStepCommand executeStepCommand = new ExecuteStepCommand { Saga = saga, SagaStep = step, SagaAction = action, Model = command.Model }; logger. LogDebug($"Saga: {saga.Data.ID}; Executing {(step.Async ? "async " : "")}step: {step.StepName}"); if (step.Async) { DispatchStepAsync(executeStepCommand); return(saga); } else { using (IServiceScope scope = serviceScopeFactory.CreateScope()) { return(await DispatchStepSync(scope.ServiceProvider, executeStepCommand)); } } }
private void InitializeCommands() { NewProjectCommand = new NewProjectCommand(this); SaveChangesCommand = new SaveChangesCommand(this); RemoveSelectedNewActionCommand = new RemoveSelectedNewActionCommand(this); OpenFileCommand = new OpenFileCommand(this); ExecuteActionCommand = new ExecuteActionCommand(this); OpenAddActionDialogCommand = new OpenAddActionDialogCommand(this); CloseAddActionDialogCommand = new CloseAddActionDialogCommand(this); RegisterCommand(NewProjectCommand); RegisterCommand(SaveChangesCommand); RegisterCommand(RemoveSelectedNewActionCommand); RegisterCommand(OpenFileCommand); RegisterCommand(ExecuteActionCommand); RegisterCommand(OpenAddActionDialogCommand); RegisterCommand(CloseAddActionDialogCommand); RaiseCanExecuteCommandChanged(); }