Description of WizardStepCmdletBase.
Наследование: WizardConstructionCmdletBase
Пример #1
0
        public static void AddWizardStep(WizardStepCmdletBase cmdlet)
        {
            if (null != cmdlet.InputObject && null != cmdlet.InputObject)
            {
                WizardStep probeTheSameStep = cmdlet.InputObject.GetStep(cmdlet.Name);
                if (null != probeTheSameStep)
                {
                    cmdlet.WriteError(
                        cmdlet,
                        "A step with the name provided already exists",
                        "StepAlreadyExists",
                        ErrorCategory.InvalidArgument,
                        true);
                }

                // WizardStep step = new WizardStep(cmdlet.Name, cmdlet.Order)
                var step = new WizardStep(cmdlet.Name, cmdlet.Order)
                {
                    SearchCriteria     = cmdlet.SearchCriteria,
                    StepForwardAction  = cmdlet.StepForwardAction,
                    StepBackwardAction = cmdlet.StepBackwardAction,
                    StepCancelAction   = cmdlet.StepCancelAction,
                    Description        = cmdlet.Description,
                    Parent             = cmdlet.InputObject
                };
                // 20130319
                //step.StepGetWindowAction = cmdlet.StepGetWindowAction;

                cmdlet.WriteVerbose(cmdlet, "adding the step");
                cmdlet.InputObject.Steps.Add(step);

                // 20130508
                cmdlet.WriteInfo(cmdlet, step.Name + " has been added");

                if (cmdlet.PassThru)
                {
                    cmdlet.WriteObject(cmdlet, cmdlet.InputObject);
                }
                else
                {
                    cmdlet.WriteObject(cmdlet, true);
                }
            }
            else
            {
                cmdlet.WriteError(cmdlet, "The wizard object you provided is not valid", "WrongWizardObject", ErrorCategory.InvalidArgument, true);
            }
        }
Пример #2
0
        public static void AddWizardStep(WizardStepCmdletBase cmdlet)
        {
            if (null != cmdlet.InputObject && null != cmdlet.InputObject) {
                
                WizardStep probeTheSameStep = cmdlet.InputObject.GetStep(cmdlet.Name);
                if (null != probeTheSameStep) {
                    
                    cmdlet.WriteError(
                        cmdlet,
                        "A step with the name provided already exists",
                        "StepAlreadyExists",
                        ErrorCategory.InvalidArgument,
                        true);
                }
                
                // WizardStep step = new WizardStep(cmdlet.Name, cmdlet.Order)
                var step = new WizardStep(cmdlet.Name, cmdlet.Order)
                {
                    SearchCriteria = cmdlet.SearchCriteria,
                    StepForwardAction = cmdlet.StepForwardAction,
                    StepBackwardAction = cmdlet.StepBackwardAction,
                    StepCancelAction = cmdlet.StepCancelAction,
                    Description = cmdlet.Description,
                    Parent = cmdlet.InputObject
                };
                // 20130319
                //step.StepGetWindowAction = cmdlet.StepGetWindowAction;
                
                cmdlet.WriteVerbose(cmdlet, "adding the step");
                cmdlet.InputObject.Steps.Add(step);
                
                // 20130508
                cmdlet.WriteInfo(cmdlet, step.Name + " has been added");

                if (cmdlet.PassThru) {

                    cmdlet.WriteObject(cmdlet, cmdlet.InputObject);
                } else {

                    cmdlet.WriteObject(cmdlet, true);
                }
            } else {

                cmdlet.WriteError(cmdlet, "The wizard object you provided is not valid", "WrongWizardObject", ErrorCategory.InvalidArgument, true);
            }
        }