private static ApplicationInfo CreateApplicationInfoFromXml(string appFolder, XmlNode nodeApp)
        {
            ApplicationInfo app = new ApplicationInfo();

            // category name
            app.CategoryName = GetNodeValue(nodeApp, "category", "");

            // attributes
            app.Id = nodeApp.Attributes["id"].Value;
            app.Codebase = nodeApp.Attributes["codebase"].Value;
            app.SettingsControl = nodeApp.Attributes["settingsControl"].Value;
            app.Folder = appFolder;

            // child nodes
            app.Name = GetNodeValue(nodeApp, "name", "");
            app.ShortDescription = GetNodeValue(nodeApp, "shortDescription", "");
            app.FullDescription = GetNodeValue(nodeApp, "fullDescription", "");
            app.Logo = GetNodeValue(nodeApp, "logo", "");
            app.Version = GetNodeValue(nodeApp, "version", "");
            app.Size = Int32.Parse(GetNodeValue(nodeApp, "size", "0"));
            app.HomeSite = GetNodeValue(nodeApp, "homeSite", "");
            app.SupportSite = GetNodeValue(nodeApp, "supportSite", "");
            app.DocsSite = GetNodeValue(nodeApp, "docSite", "");

            app.Manufacturer = GetNodeValue(nodeApp, "manufacturer", "");
            app.License = GetNodeValue(nodeApp, "license", "");

            // process codebase path
            app.Codebase = Path.Combine(appFolder, app.Codebase);

            // web settings
            List<ApplicationWebSetting> settings = new List<ApplicationWebSetting>();
            XmlNodeList nodesWebSettings = nodeApp.SelectNodes("webSettings/add");
            foreach (XmlNode nodeSetting in nodesWebSettings)
            {
                ApplicationWebSetting setting = new ApplicationWebSetting();
                setting.Name = nodeSetting.Attributes["name"].Value;
                setting.Value = nodeSetting.Attributes["value"].Value;
                settings.Add(setting);
            }
            app.WebSettings = settings.ToArray();

            // requirements
            List<ApplicationRequirement> requirements = new List<ApplicationRequirement>();
            XmlNodeList nodesRequirements = nodeApp.SelectNodes("requirements/add");
            foreach (XmlNode nodesRequirement in nodesRequirements)
            {
                ApplicationRequirement req = new ApplicationRequirement();

                if (nodesRequirement.Attributes["group"] != null)
                    req.Groups = nodesRequirement.Attributes["group"].Value.Split('|');

                if (nodesRequirement.Attributes["quota"] != null)
                    req.Quotas = nodesRequirement.Attributes["quota"].Value.Split('|');

                req.Display = true;
                if (nodesRequirement.Attributes["display"] != null)
                    req.Display = Utils.ParseBool(nodesRequirement.Attributes["display"].Value, true);

                requirements.Add(req);
            }
            app.Requirements = requirements.ToArray();

            return app;
        }
示例#2
0
        private static ApplicationInfo CreateApplicationInfoFromXml(string appFolder, XmlNode nodeApp)
        {
            ApplicationInfo app = new ApplicationInfo();

            // category name
            app.CategoryName = GetNodeValue(nodeApp, "category", "");

            // attributes
            app.Id              = nodeApp.Attributes["id"].Value;
            app.Codebase        = nodeApp.Attributes["codebase"].Value;
            app.SettingsControl = nodeApp.Attributes["settingsControl"].Value;
            app.Folder          = appFolder;

            // child nodes
            app.Name             = GetNodeValue(nodeApp, "name", "");
            app.ShortDescription = GetNodeValue(nodeApp, "shortDescription", "");
            app.FullDescription  = GetNodeValue(nodeApp, "fullDescription", "");
            app.Logo             = GetNodeValue(nodeApp, "logo", "");
            app.Version          = GetNodeValue(nodeApp, "version", "");
            app.Size             = Int32.Parse(GetNodeValue(nodeApp, "size", "0"));
            app.HomeSite         = GetNodeValue(nodeApp, "homeSite", "");
            app.SupportSite      = GetNodeValue(nodeApp, "supportSite", "");
            app.DocsSite         = GetNodeValue(nodeApp, "docSite", "");

            app.Manufacturer = GetNodeValue(nodeApp, "manufacturer", "");
            app.License      = GetNodeValue(nodeApp, "license", "");

            // process codebase path
            app.Codebase = Path.Combine(appFolder, app.Codebase);

            // web settings
            List <ApplicationWebSetting> settings = new List <ApplicationWebSetting>();
            XmlNodeList nodesWebSettings          = nodeApp.SelectNodes("webSettings/add");

            foreach (XmlNode nodeSetting in nodesWebSettings)
            {
                ApplicationWebSetting setting = new ApplicationWebSetting();
                setting.Name  = nodeSetting.Attributes["name"].Value;
                setting.Value = nodeSetting.Attributes["value"].Value;
                settings.Add(setting);
            }
            app.WebSettings = settings.ToArray();

            // requirements
            List <ApplicationRequirement> requirements = new List <ApplicationRequirement>();
            XmlNodeList nodesRequirements = nodeApp.SelectNodes("requirements/add");

            foreach (XmlNode nodesRequirement in nodesRequirements)
            {
                ApplicationRequirement req = new ApplicationRequirement();

                if (nodesRequirement.Attributes["group"] != null)
                {
                    req.Groups = nodesRequirement.Attributes["group"].Value.Split('|');
                }

                if (nodesRequirement.Attributes["quota"] != null)
                {
                    req.Quotas = nodesRequirement.Attributes["quota"].Value.Split('|');
                }

                req.Display = true;
                if (nodesRequirement.Attributes["display"] != null)
                {
                    req.Display = Utils.ParseBool(nodesRequirement.Attributes["display"].Value, true);
                }

                requirements.Add(req);
            }
            app.Requirements = requirements.ToArray();

            return(app);
        }