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 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 TestUserControlImage() { Console.WriteLine("TestUserControlImage"); ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); ControlImage image = new ControlImage(); image.ResourceId = "RES_BANNER_DOESNTEXIST"; setupConfiguration.Children.Add(image); ComponentCmd cmd = new ComponentCmd(); cmd.command = "cmd.exe /C exit /b 0"; setupConfiguration.Children.Add(cmd); string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); Assert.AreEqual(-1, dotNetInstallerExeUtils.Run(configFilename)); image.ResourceId = "RES_BANNER"; configFile.SaveAs(configFilename); Assert.AreEqual(0, dotNetInstallerExeUtils.Run(configFilename)); File.Delete(configFilename); }