internal static void PrepareStepDirections(WizardRunCmdletBase cmdlet, Wizard wzd) { foreach (Dictionary<string, object> dictDirections in cmdlet.DirectionsDictionaries) { WizardStep stepWithDirections = null; string stepWithDirectionsName = string.Empty; try { stepWithDirectionsName = dictDirections["STEP"].ToString(); if ("0" == stepWithDirectionsName) { // } else { stepWithDirections = wzd.GetStep(stepWithDirectionsName); if (null == stepWithDirections) { cmdlet.WriteError( cmdlet, "Failed to get a step with name '" + stepWithDirectionsName + "' in the Directions hashtable.", "FailedToGetStep", ErrorCategory.InvalidArgument, true); } } try { switch (dictDirections["ACTION"].ToString().ToUpper()) { case "FORWARD": stepWithDirections.ToDo = WizardStepActions.Forward; break; case "BACKWARD": stepWithDirections.ToDo = WizardStepActions.Backward; break; case "CANCEL": stepWithDirections.ToDo = WizardStepActions.Cancel; break; case "STOP": stepWithDirections.ToDo = WizardStepActions.Stop; break; default: throw new Exception("Invalid value for directions"); //stepWithDirections.ToDo = WizardStepActions.Forward; //break; } } catch (Exception eActionType) { cmdlet.WriteVerbose( cmdlet, "The action parameter: " + eActionType.Message); } } catch (Exception eDirectionsDictionaries) { cmdlet.WriteError( cmdlet, "Failed to parse directions for step '" + stepWithDirectionsName + "'. " + eDirectionsDictionaries.Message, "FailedToParseDirections", ErrorCategory.InvalidArgument, true); } } }
internal static void PrepareStepDirections(WizardRunCmdletBase cmdlet, Wizard wzd) { foreach (Dictionary <string, object> dictDirections in cmdlet.DirectionsDictionaries) { WizardStep stepWithDirections = null; string stepWithDirectionsName = string.Empty; try { stepWithDirectionsName = dictDirections["STEP"].ToString(); if ("0" == stepWithDirectionsName) { // } else { stepWithDirections = wzd.GetStep(stepWithDirectionsName); if (null == stepWithDirections) { cmdlet.WriteError( cmdlet, "Failed to get a step with name '" + stepWithDirectionsName + "' in the Directions hashtable.", "FailedToGetStep", ErrorCategory.InvalidArgument, true); } } try { switch (dictDirections["ACTION"].ToString().ToUpper()) { case "FORWARD": stepWithDirections.ToDo = WizardStepActions.Forward; break; case "BACKWARD": stepWithDirections.ToDo = WizardStepActions.Backward; break; case "CANCEL": stepWithDirections.ToDo = WizardStepActions.Cancel; break; case "STOP": stepWithDirections.ToDo = WizardStepActions.Stop; break; default: throw new Exception("Invalid value for directions"); //stepWithDirections.ToDo = WizardStepActions.Forward; //break; } } catch (Exception eActionType) { cmdlet.WriteVerbose( cmdlet, "The action parameter: " + eActionType.Message); } } catch (Exception eDirectionsDictionaries) { cmdlet.WriteError( cmdlet, "Failed to parse directions for step '" + stepWithDirectionsName + "'. " + eDirectionsDictionaries.Message, "FailedToParseDirections", ErrorCategory.InvalidArgument, true); } } }
// 20130325 // these were an action in the Parameters hashtable (the outer hashtable): // @{step="Step05PrinterData";action="forward";parameters=@{action="forward";list=@("printer_2","port_2")}} #region commented // try { // // switch (dictParameters["ACTION"].ToString().ToUpper()) { // case "FORWARD": // stepWithParameters.ToDo = WizardStepActions.Forward; // break; // case "BACKWARD": // stepWithParameters.ToDo = WizardStepActions.Backward; // break; // case "CANCEL": // stepWithParameters.ToDo = WizardStepActions.Cancel; // break; // case "STOP": // stepWithParameters.ToDo = WizardStepActions.Stop; // break; // default: // // nothing to do // break; // } // } // catch (Exception eActionType) { // // cmdlet.WriteVerbose( // cmdlet, // "The action parameter: " + // eActionType.Message); // } #endregion commented // these were a hashtable of parameters in the outerhashtable // @{step="Step05PrinterData";action="forward";parameters=@{action="forward";list=@("printer_2","port_2")}} #region commented // Hashtable parameters = // (Hashtable)dictParameters["PARAMETERS"]; // // if (null != parameters) { // // switch (parameters["ACTION"].ToString().ToUpper()) { // case "FORWARD": // stepWithParameters.StepForwardActionParameters = (object[])parameters["LIST"]; // break; // case "BACKWARD": // stepWithParameters.StepBackwardActionParameters = (object[])parameters["LIST"]; // break; // case "CANCEL": // stepWithParameters.StepCancelActionParameters = (object[])parameters["LIST"]; // break; // default: // // nothing to do // break; // } // // } else { // // cmdlet.WriteVerbose( // cmdlet, // "Parameters: " + // "parameters hashtable is null."); // } #endregion commented // 20130322 internal static void PrepareStepParameters(WizardRunCmdletBase cmdlet, Wizard wzd) { foreach (Dictionary<string, object> dictParameters in cmdlet.ParametersDictionaries) { WizardStep stepWithParameters = null; string stepWithParametersName = string.Empty; try { stepWithParametersName = dictParameters["STEP"].ToString(); if ("0" == stepWithParametersName) { // } else { stepWithParameters = wzd.GetStep(stepWithParametersName); if (null == stepWithParameters) { cmdlet.WriteError( cmdlet, "Failed to get a step with name '" + stepWithParametersName + "' in the Parameters hashtable.", "FailedToGetStep", ErrorCategory.InvalidArgument, true); } } try { switch (dictParameters["ACTION"].ToString().ToUpper()) { case "FORWARD": stepWithParameters.StepForwardActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "BACKWARD": stepWithParameters.StepBackwardActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "CANCEL": stepWithParameters.StepCancelActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "STOP": wzd.StopActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "START": wzd.StartActionParameters = (object[])dictParameters["PARAMETERS"]; break; default: break; } } catch (Exception eParameters) { cmdlet.WriteVerbose( cmdlet, "Parameters: " + eParameters.Message); } } catch (Exception eParametersDictionaries) { cmdlet.WriteError( cmdlet, "Failed to parse parameters for step '" + stepWithParametersName + "'. " + eParametersDictionaries.Message, "FailedToParseParameters", ErrorCategory.InvalidArgument, true); } } }
// 20130325 // these were an action in the Parameters hashtable (the outer hashtable): // @{step="Step05PrinterData";action="forward";parameters=@{action="forward";list=@("printer_2","port_2")}} #region commented // try { // // switch (dictParameters["ACTION"].ToString().ToUpper()) { // case "FORWARD": // stepWithParameters.ToDo = WizardStepActions.Forward; // break; // case "BACKWARD": // stepWithParameters.ToDo = WizardStepActions.Backward; // break; // case "CANCEL": // stepWithParameters.ToDo = WizardStepActions.Cancel; // break; // case "STOP": // stepWithParameters.ToDo = WizardStepActions.Stop; // break; // default: // // nothing to do // break; // } // } // catch (Exception eActionType) { // // cmdlet.WriteVerbose( // cmdlet, // "The action parameter: " + // eActionType.Message); // } #endregion commented // these were a hashtable of parameters in the outerhashtable // @{step="Step05PrinterData";action="forward";parameters=@{action="forward";list=@("printer_2","port_2")}} #region commented // Hashtable parameters = // (Hashtable)dictParameters["PARAMETERS"]; // // if (null != parameters) { // // switch (parameters["ACTION"].ToString().ToUpper()) { // case "FORWARD": // stepWithParameters.StepForwardActionParameters = (object[])parameters["LIST"]; // break; // case "BACKWARD": // stepWithParameters.StepBackwardActionParameters = (object[])parameters["LIST"]; // break; // case "CANCEL": // stepWithParameters.StepCancelActionParameters = (object[])parameters["LIST"]; // break; // default: // // nothing to do // break; // } // // } else { // // cmdlet.WriteVerbose( // cmdlet, // "Parameters: " + // "parameters hashtable is null."); // } #endregion commented // 20130322 internal static void PrepareStepParameters(WizardRunCmdletBase cmdlet, Wizard wzd) { foreach (Dictionary <string, object> dictParameters in cmdlet.ParametersDictionaries) { WizardStep stepWithParameters = null; string stepWithParametersName = string.Empty; try { stepWithParametersName = dictParameters["STEP"].ToString(); if ("0" == stepWithParametersName) { // } else { stepWithParameters = wzd.GetStep(stepWithParametersName); if (null == stepWithParameters) { cmdlet.WriteError( cmdlet, "Failed to get a step with name '" + stepWithParametersName + "' in the Parameters hashtable.", "FailedToGetStep", ErrorCategory.InvalidArgument, true); } } try { switch (dictParameters["ACTION"].ToString().ToUpper()) { case "FORWARD": stepWithParameters.StepForwardActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "BACKWARD": stepWithParameters.StepBackwardActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "CANCEL": stepWithParameters.StepCancelActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "STOP": wzd.StopActionParameters = (object[])dictParameters["PARAMETERS"]; break; case "START": wzd.StartActionParameters = (object[])dictParameters["PARAMETERS"]; break; default: break; } } catch (Exception eParameters) { cmdlet.WriteVerbose( cmdlet, "Parameters: " + eParameters.Message); } } catch (Exception eParametersDictionaries) { cmdlet.WriteError( cmdlet, "Failed to parse parameters for step '" + stepWithParametersName + "'. " + eParametersDictionaries.Message, "FailedToParseParameters", ErrorCategory.InvalidArgument, true); } } }