public static Control CreateFromXml(XmlElement element) { string xmltype = element.Attributes["type"].InnerText; Control control = null; ControlType type = (ControlType)Enum.Parse(typeof(ControlType), xmltype); switch (type) { case ControlType.label: control = new ControlLabel(); break; case ControlType.checkbox: control = new ControlCheckBox(); break; case ControlType.edit: control = new ControlEdit(); break; case ControlType.browse: control = new ControlBrowse(); break; case ControlType.license: control = new ControlLicense(); break; case ControlType.hyperlink: control = new ControlHyperlink(); break; case ControlType.image: control = new ControlImage(); break; default: throw new Exception(string.Format("Invalid type: {0}", xmltype)); } control.FromXml(element); return(control); }
public void TestUserControlBrowseBackslashStripped() { Console.WriteLine("TestUserControlBrowseBackslashStripped"); ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); ControlBrowse browse = new ControlBrowse(); browse.Text = @"42\"; browse.Id = "browse1"; setupConfiguration.Children.Add(browse); ComponentCmd cmd = new ComponentCmd(); cmd.command = "cmd.exe /C if \"[browse1]\"==\"42\" ( exit /b 0 ) else ( exit /b 1 )"; setupConfiguration.Children.Add(cmd); // save config file string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); // execute dotNetInstaller Assert.AreEqual(0, dotNetInstallerExeUtils.Run(configFilename)); File.Delete(configFilename); }
public void TestUserControlBrowse() { Console.WriteLine("TestUserControlBrowse"); ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); ControlBrowse browse = new ControlBrowse(); browse.Text = "4"; browse.Id = "browse1"; setupConfiguration.Children.Add(browse); ComponentCmd cmd = new ComponentCmd(); cmd.command = "cmd.exe /C exit /b [browse1]"; cmd.required_install = true; setupConfiguration.Children.Add(cmd); // save config file string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); // execute dotNetInstaller Assert.AreEqual(4, dotNetInstallerExeUtils.Run(configFilename)); File.Delete(configFilename); }
public static Control CreateFromXml(XmlElement element) { string xmltype = element.Attributes["type"].InnerText; Control control = null; ControlType type = (ControlType)Enum.Parse(typeof(ControlType), xmltype); switch (type) { case ControlType.label: control = new ControlLabel(); break; case ControlType.checkbox: control = new ControlCheckBox(); break; case ControlType.edit: control = new ControlEdit(); break; case ControlType.browse: control = new ControlBrowse(); break; case ControlType.license: control = new ControlLicense(); break; case ControlType.hyperlink: control = new ControlHyperlink(); break; case ControlType.image: control = new ControlImage(); break; default: throw new Exception(string.Format("Invalid type: {0}", xmltype)); } control.FromXml(element); return control; }