public async Task <IProvisioningState?> GetNextStateAsync(
            NextStateContext context)
        {
            switch (context.CurrentState)
            {
            case ICreateLightsailInstanceState createLightsailInstanceState:
                return(TransitionFromCreateToInstall(context.StateFactory, createLightsailInstanceState));

            case IInstallSoftwareOnInstanceState installDockerOnInstanceState:
                return(TransitionFromInstallToComplete(context.StateFactory, installDockerOnInstanceState));

            case ICompleteInstanceSetupState _:
                return(null);

            default:
                throw new UnknownFlowStateException($"Could not determine the next state for a state of type {context.CurrentState.GetType().FullName}.");
            }
        }
        public async Task <IProvisioningState?> GetNextStateAsync(NextStateContext context)
        {
            var nextState = await this.currentFlow.GetNextStateAsync(context);

            if (nextState != null)
            {
                return(nextState);
            }

            if (this.currentFlow == this.lastFlow)
            {
                return(null);
            }

            var currentFlowIndex = this.flows.IndexOf(this.currentFlow);

            this.currentFlow = this.flows[currentFlowIndex + 1];

            return(await this.currentFlow.GetInitialStateAsync(
                       new InitialStateContext(
                           context.Mediator,
                           context.StateFactory)));
        }
 public async Task <IProvisioningState?> GetNextStateAsync(NextStateContext context)
 {
     return(null);
 }