Ejemplo n.º 1
0
        private static List <string> CreateCodeBlock(int indent, PowerShellCodeBlock package)
        {
            var obj = PsObject.GetPSObject();

            obj.AppendProperty(NewProp("install", package.Install.ToString()));
            obj.AppendProperty(NewProp("type", package.Type.ToString()));
            obj.AppendProperty(NewProp("displayName", package.DisplayName));

            if (!string.IsNullOrEmpty(package.Code.Trim()))
            {
                var arguments = PsArray.GetArrayProperty("PSCodeBlock");
                // goes over each line in the arguments configured
                using (StringReader sr = new StringReader(package.Code))
                {
                    string codeLine;
                    int    lines = 0;
                    while ((codeLine = sr.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(codeLine))
                        {
                            lines++;
                            arguments.AppendProperty($"'{codeLine}'");
                        }
                    }
                }

                obj.AppendItem(arguments.ToList(indent));
            }

            return(obj.ToList(indent));
        }
Ejemplo n.º 2
0
        public void TestCanInsertPackage()
        {
            var model    = new InstallModel();
            var package1 = new PIDataArchive()
            {
                DisplayName = "1"
            };
            var package2 = new PowerShellCodeBlock()
            {
                DisplayName = "2"
            };
            var package3 = new PowerShellCodeBlock()
            {
                DisplayName = "3"
            };

            model.Add(package1);
            model.Add(package2);

            Assert.IsTrue(model.Items[0].Id == package1.Id, "package 1 is first");
            Assert.IsTrue(model.Items[1].Id == package2.Id, "package 2 is second");


            model.Add(package3, package2);

            Assert.IsTrue(model.Items[0].Id == package1.Id, "package 1 is first");
            Assert.IsTrue(model.Items[1].Id == package3.Id, "package 3 is second");
            Assert.IsTrue(model.Items[2].Id == package2.Id, "package 2 is third");



            model.Remove(package1);
        }
        private void btnNewPowershellScript_Click(object sender, EventArgs e)
        {
            var step = new PowerShellCodeBlock();

            _model.Add(step);

            Program.ShowPackageEditor(step);
        }
Ejemplo n.º 4
0
        private void btnNewPowershellScript_Click(object sender, EventArgs e)
        {
            PowerShellBlockCount++;
            var step = new PowerShellCodeBlock(PowerShellBlockCount);

            _model.Add(step);

            if (UserSettings.Default.UIOpenEditorOnAdd)
            {
                Program.ShowPackageEditor(step);
            }
        }
Ejemplo n.º 5
0
        public void TestCanAddNewInstallPackages()
        {
            var model    = new InstallModel();
            var package1 = new PIDataArchive();
            var package2 = new Executable();
            var package3 = new OSIAutoExtractSetupPackage();
            var package4 = new PowerShellCodeBlock();

            model.Add(package1);
            model.Add(package2);
            model.Add(package3);
            model.Add(package4);

            Assert.IsTrue(model.Items.Count == 4);
        }
Ejemplo n.º 6
0
        public static InstallModel GetTestModel()
        {
            var model    = new InstallModel();
            var package1 = new OSIAutoExtractSetupPackage()
            {
                DisplayName       = "package 1"
                , IniReplacements = new BindingList <IniReplacement>()
                {
                    new IniReplacement()
                    {
                        DefaultValue = "16 = ...", ReplaceValue = "16 = abc"
                    }
                }
                , FileInfo = new PackageFileInfo()
                {
                    FilePath = "c:\\test.exe"
                }
            };
            var package2 = new PowerShellCodeBlock()
            {
                DisplayName = "package 2", Code = "Restart-Computer",
            };
            var package3 = new Executable()
            {
                DisplayName = "Executable package", Arguments = "/silent"
            };
            var package4 = new PIDataArchive()
            {
                DisplayName = "PI DA package", IniReplacements = new BindingList <IniReplacement>()
                {
                    new IniReplacement()
                    {
                        DefaultValue = "16 = ...", ReplaceValue = "16 = abc"
                    }
                }
            };

            model.Add(package1);
            model.Add(package2);
            model.Add(package3);
            model.Add(package4);

            return(model);
        }
Ejemplo n.º 7
0
        public void TestCanRemovePackage()
        {
            var model    = new InstallModel();
            var package1 = new PIDataArchive()
            {
                DisplayName = "1"
            };
            var package2 = new PowerShellCodeBlock()
            {
                DisplayName = "2"
            };

            model.Add(package1);
            model.Add(package2);

            model.Remove(package1);

            Assert.IsTrue(model.Items[0].Id == package2.Id, "remaining item is package 2");
            Assert.IsTrue(model.Items.Count == 1, "only one item in the list");
        }
        public void SetModel(object model)
        {
            _model = model as PowerShellCodeBlock;

            ConfigureDataBindings();
        }