Esempio n. 1
0
 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 TestUserControlHyperlink()
        {
            Console.WriteLine("TestUserControlHyperlink");

            ConfigFile configFile = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            ControlHyperlink hyperlink = new ControlHyperlink();
            hyperlink.Text = "url";
            hyperlink.Uri = "http://dotnetinstaller.codeplex.com";
            setupConfiguration.Children.Add(hyperlink);
            ComponentCmd cmd = new ComponentCmd();
            cmd.command = "cmd.exe /C exit /b 0";
            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);
        }