Example #1
0
        public static Configuration CreateFromXml(XmlElement element)
        {
            Configuration l_Config;
            XmlAttribute  xmltypeAttribute = element.Attributes["type"];

            if (xmltypeAttribute == null)
            {
                throw new Exception(string.Format("Missing configuration type at \"{0}\".", element.Name));
            }

            string xmltype = xmltypeAttribute.InnerText;

            switch (xmltype)
            {
            case "install":
                l_Config = new SetupConfiguration();
                break;

            case "reference":
                l_Config = new WebConfiguration();
                break;

            default:
                throw new Exception(string.Format("Invalid configuration type: {0}", xmltype));
            }

            l_Config.FromXml(element);
            return(l_Config);
        }
 public void TestDisplayConfigWebConfiguration()
 {
     // config file with a web configuration (that will not be downloaded)
     ConfigFile configFile = new ConfigFile();
     string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
     WebConfiguration webConfiguration = new WebConfiguration();
     DownloadDialog downloadDialog = new DownloadDialog();
     downloadDialog.Children.Add(new Download());
     webConfiguration.Children.Add(downloadDialog);
     configFile.Children.Add(webConfiguration);
     Console.WriteLine("Writing '{0}'", configFilename);
     configFile.SaveAs(configFilename);
     // execute
     dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
     options.args = "/qb /DisplayConfig";
     options.log = false;
     options.quiet = false;
     Assert.AreEqual(0, dotNetInstallerExeUtils.Run(options));
     // cleanup
     File.Delete(configFilename);
 }
        public static Configuration CreateFromXml(XmlElement element)
        {
            Configuration l_Config;
            XmlAttribute xmltypeAttribute = element.Attributes["type"];
            if (xmltypeAttribute == null)
            {
                throw new Exception(string.Format("Missing configuration type at \"{0}\".", element.Name));
            }

            string xmltype = xmltypeAttribute.InnerText;
            switch (xmltype)
            {
                case "install":
                    l_Config = new SetupConfiguration();
                    break;
                case "reference":
                    l_Config = new WebConfiguration();
                    break;
                default:
                    throw new Exception(string.Format("Invalid configuration type: {0}", xmltype));
            }

            l_Config.FromXml(element);
            return l_Config;
        }