コード例 #1
0
        public static SingleWorkflowStep CreateStep(XmlNode node)
        {
            SingleWorkflowStep toret = null;
            string workflowType = node.Name.ToUpperInvariant();
            switch (workflowType)
            {
                case ("IF"):
                    {
                        toret = new IfWorkflowStep
                        {
                            Help = node.GetAttribute("help"),
                            Is = node.GetAttribute("is"),
                            Value = node.GetAttribute("value"),
                            MustBeTrue = node.IsAttributeSet("not") == false
                        };
                    }
                    break;
                case ("DOWHILE"):
                    {
                        toret = new DoWhileStep
                        {
                            Help = node.GetAttribute("help"),
                            Is = node.GetAttribute("is"),
                            Value = node.GetAttribute("value"),
                            MustBeTrue = node.IsAttributeSet("not") == false
                        };
                    }
                    break;
                case ("DELETE"):
                    {
                        toret = new DeleteWorkflowStep
                        {
                            Help = node.GetAttribute("help"),
                            From = node.GetAttribute("from")
                        };
                    }
                    break;
                case ("DELETETEMPLATE"):
                    {
                        toret = new DeleteTemplateStep
                        {
                            From = node.GetAttribute("from")
                        };
                    }
                    break;
                case ("ASK"):
                    {
                        toret = new AskWorkflowStep
                        {
                            Help = node.GetAttribute("help"),
                            For = node.GetAttribute("for"),
                            ApplyOn = node.GetAttribute("applyOn"),
                            Value = node.GetAttribute("value")
                        };
                    }
                    break;
                case ("COPY"):
                    {
                        toret = new CopyWorkflowStep
                        {
                            Help = node.GetAttribute("help"),
                            From = node.GetAttribute("from"),
                            To = node.GetAttribute("to"),
                            What = node.GetAttribute("what")
                        };

                    }
                    break;
                case ("TELL"):
                    {
                        toret = new TellWorkflowStep
                        {
                            Help = node.GetAttribute("help"),
                            ApplyOn = node.GetAttribute("applyOn"),
                            Value = node.GetAttribute("value")
                        };
                    }
                    break;
                case ("WRITETEMPLATE"):
                    {
                        toret = new WriteTemplateStep
                        {
                            Help = node.GetAttribute("help"),
                            To = node.GetAttribute("to"),
                            Template = node.GetAttribute("template")
                        };
                    }
                    break;
                case ("PARAM"):
                    {
                        toret = new ParamStep
                        {
                            Name = node.GetAttribute("name"),
                            Value = node.GetAttribute("value")
                        };
                    }
                    break;
                case ("SWITCH"):
                    {
                        toret = new SwitchWorkflowStep
                        {
                            Value = node.GetAttribute("value")
                        };
                    }
                    break;
                case ("CASE"):
                    {
                        toret = new CaseWorkflowStep
                        {
                            Value = node.GetAttribute("value")
                        };
                    }
                    break;
                case ("INCLUDE"):
                    {
                        toret = new IncludeStep();
                    }
                    break;
                default:
                    foreach (var factory in _factories)
                    {
                        toret = factory.Value.Create(workflowType, node);
                        if (toret != null) break;
                    }
                    break;
            }

            return toret;
        }
コード例 #2
0
 public override SingleWorkflowStep Undo()
 {
     var to = DoAllReplaces(To);
     var destinationPath = _setupFile.GetKey("DestinationPath");
     var destinationFile = Path.Combine(destinationPath, to);
     if (_setupFile.Unattended)
     {
         return new DeleteTemplateStep
             {
                 From = destinationFile,
                 Help = string.Format("Delete {0}", destinationFile)
             };
     }
     var varName = Guid.NewGuid().ToString();
     var toret = new AskWorkflowStep
         {
             Help = string.Format("Sould be {0} deleted?", destinationFile),
             For = "YesNo",
             ApplyOn = "${" + varName + "}"
         };
     var ifStep = new IfWorkflowStep
         {
             Value = "${" + varName + "}",
             Is = "true"
         };
     toret.WorkflowSteps.Add(ifStep);
     ifStep.WorkflowSteps.Add(new DeleteTemplateStep
         {
             From = destinationFile
         });
     return toret;
 }