Exemplo n.º 1
0
        protected void ResetSteps(Controller controller)
        {
            IWizardController wizardController = controller as IWizardController;

            WizardStepPage[] steps = wizardController.GetSteps(controller.Context);

            foreach (WizardStepPage step in steps)
            {
                step.Reset();
            }
        }
Exemplo n.º 2
0
        public void IncludeActions(Controller controller)
        {
            IRailsEngineContext context = controller.Context;

            IWizardController wizardController = controller as IWizardController;

            if (wizardController == null)
            {
                throw new RailsException("The controller {0} must implement the interface " +
                                         "IWizardController to be used as a wizard", controller.Name);
            }

            steps = wizardController.GetSteps(controller.Context);

            if (steps == null || steps.Length == 0)
            {
                throw new RailsException("The controller {0} returned no WizardStepPage",
                                         controller.Name);
            }

            IList stepList = new ArrayList();

            controller.DynamicActions["start"] = this;

            urlInfo = controller.Context.UrlInfo;

            rawAction = urlInfo.Action;

            requestedAction = ObtainRequestedAction(rawAction, out innerAction);

            foreach (WizardStepPage step in steps)
            {
                String actionName = step.ActionName;

                if (String.Compare(requestedAction, actionName, true) == 0)
                {
                    currentStepInstance = step;

                    if (innerAction != null)
                    {
                        // If there's an inner action, we invoke it as a step too
                        controller.DynamicActions[rawAction] =
                            new DelegateDynamicAction(new ActionDelegate(OnStepActionRequested));
                    }
                }

                controller.DynamicActions[actionName] =
                    new DelegateDynamicAction(new ActionDelegate(OnStepActionRequested));

                stepList.Add(actionName);

                step.Initialize(controller);
            }

            context.UnderlyingContext.Items["wizard.step.list"] = stepList;

            if (currentStepInstance != null && !HasRequiredSessionData(controller))
            {
                StartWizard(controller, false);
            }

            SetUpWizardHelper(controller);
            SetUpWizardHelper(currentStepInstance);
        }