Exemple #1
0
        public static CombineDescriptor CreateCombineDescriptor(XmlElement element, string hintPath)
        {
            CombineDescriptor combineDescriptor = new CombineDescriptor(element.Attributes["name"].InnerText);

            if (element.Attributes["directory"] != null)
            {
                combineDescriptor.relativeDirectory = element.Attributes["directory"].InnerText;
            }

            if (element["Options"] != null && element["Options"]["StartupProject"] != null)
            {
                combineDescriptor.startupProject = element["Options"]["StartupProject"].InnerText;
            }

            combineDescriptor.mainFolder.Read(element, hintPath);
            return(combineDescriptor);
        }
		public static CombineDescriptor CreateCombineDescriptor(XmlElement element, string hintPath)
		{
			CombineDescriptor combineDescriptor = new CombineDescriptor(element.Attributes["name"].InnerText);
			
			if (element.Attributes["directory"] != null) {
				combineDescriptor.relativeDirectory = element.Attributes["directory"].InnerText;
			}
			
			if (element["Options"] != null && element["Options"]["StartupProject"] != null) {
				combineDescriptor.startupProject = element["Options"]["StartupProject"].InnerText;
			}
			
			combineDescriptor.mainFolder.Read(element, hintPath);
			return combineDescriptor;
		}
        void LoadFromXml(XmlElement templateElement, string xmlFileName)
        {
            // required for warning messages for unknown elements
            templateElement.SetAttribute("fileName", xmlFileName);

            originator   = templateElement.GetAttribute("originator");
            created      = templateElement.GetAttribute("created");
            lastmodified = templateElement.GetAttribute("lastModified");

            string newProjectDialogVisibleAttr = templateElement.GetAttribute("newprojectdialogvisible");

            if (string.Equals(newProjectDialogVisibleAttr, "false", StringComparison.OrdinalIgnoreCase))
            {
                newProjectDialogVisible = false;
            }

            XmlElement config = templateElement["TemplateConfiguration"];

            if (config["Wizard"] != null)
            {
                wizardpath = config["Wizard"].InnerText;
            }

            name     = config["Name"].InnerText;
            category = config["Category"].InnerText;

            if (config["LanguageName"] != null)
            {
                languagename = config["LanguageName"].InnerText;
                WarnObsoleteNode(config["LanguageName"], "use language attribute on the project node instead");
            }

            if (config["Subcategory"] != null)
            {
                subcategory = config["Subcategory"].InnerText;
            }

            if (config["Description"] != null)
            {
                description = config["Description"].InnerText;
            }

            if (config["Icon"] != null)
            {
                icon = config["Icon"].InnerText;
            }

            string hintPath = Path.GetDirectoryName(xmlFileName);

            if (templateElement["Solution"] != null)
            {
                combineDescriptor = CombineDescriptor.CreateCombineDescriptor(templateElement["Solution"], hintPath);
            }
            else if (templateElement["Combine"] != null)
            {
                combineDescriptor = CombineDescriptor.CreateCombineDescriptor(templateElement["Combine"], hintPath);
                WarnObsoleteNode(templateElement["Combine"], "Use <Solution> instead!");
            }

            if (templateElement["Project"] != null)
            {
                projectDescriptor = new ProjectDescriptor(templateElement["Project"], hintPath);
            }

            if (combineDescriptor == null && projectDescriptor == null ||
                combineDescriptor != null && projectDescriptor != null)
            {
                throw new TemplateLoadException("Template must contain either Project or Solution node!");
            }

            // Read Actions;
            if (templateElement["Actions"] != null)
            {
                foreach (XmlElement el in templateElement["Actions"])
                {
                    actions.Add(new OpenFileAction(el.Attributes["filename"].InnerText));
                }
            }
        }