Ejemplo n.º 1
0
        private Task ExecuteStepInternal(SetupStepInvocation invocation, ObjectValidationCallback validationCallback)
        {
            AbstractSetupStep step = this._setupSteps.Value[invocation.SetupStepNumber];

            object data = DeserializeData(invocation, validationCallback, step.DataType);

            return(step.Execute(data));
        }
Ejemplo n.º 2
0
        private static object DeserializeData(SetupStepInvocation invocation, ObjectValidationCallback validationCallback, Type dataType)
        {
            object data = null;

            if (dataType != null)
            {
                if (invocation.Data == null)
                {
                    throw new InvalidOperationException("Data parameter is null");
                }

                data = invocation.Data.ToObject(dataType);
                if (!validationCallback.Invoke(data))
                {
                    throw new SetupValidationException($"Unable to validate data of type {dataType}");
                }
            }
            return(data);
        }
Ejemplo n.º 3
0
        public async Task <SetupStepDescriptor> ExecuteStep(SetupStepInvocation invocation, ObjectValidationCallback validationCallback)
        {
            SetupStepDescriptor currentStep = await this.DetermineCurrentStep();

            if (currentStep.Order > 0 && currentStep.Order != invocation.SetupStepNumber)
            {
                this._logger.LogWarning(
                    "User attempted to execute setup step #{0} but the current step should be {1}", invocation.SetupStepNumber, currentStep.Order);

                throw new SetupWizardOutOfSyncException("Set-up kan niet worden voorgezet. Herlaad de pagina en probeer het opnieuw.");
            }

            this._logger.LogInformation("Executing setup step #{0}", invocation.SetupStepNumber);

            try {
                await this.ExecuteStepInternal(invocation, validationCallback);
            }
            catch (Exception ex) when(!(ex is SetupException))
            {
                this._logger.LogError(
                    ex,
                    "Unable to execute setup step #{0} ('{1}'): {2}",
                    currentStep.Order,
                    currentStep.Name,
                    ex.Message
                    );

                throw new SetupStepFailureException($"Set-up stap '{currentStep.Name}' kan niet worden uitgevoerd.", ex);
            }

            if (currentStep.IsDone)
            {
                return(null);
            }

            return(await this.DetermineCurrentStep());
        }