public static SolutionDescriptor CreateSolutionDescriptor(RuntimeAddin addin, XmlElement xmlElement, FilePath baseDirectory) { SolutionDescriptor solutionDescriptor = new SolutionDescriptor(); solutionDescriptor.addin = addin; if (xmlElement.Attributes["name"] != null) { solutionDescriptor.name = xmlElement.Attributes["name"].Value; } else { throw new InvalidOperationException("Attribute 'name' not found"); } if (xmlElement.Attributes["type"] != null) { solutionDescriptor.type = xmlElement.Attributes["type"].Value; } if (xmlElement.Attributes["directory"] != null) { solutionDescriptor.directory = xmlElement.Attributes["directory"].Value; } if (xmlElement["Options"] != null && xmlElement["Options"]["StartupProject"] != null) { solutionDescriptor.startupProject = xmlElement["Options"]["StartupProject"].InnerText; } foreach (XmlNode xmlNode in xmlElement.ChildNodes) { if (xmlNode is XmlElement) { XmlElement xmlNodeElement = (XmlElement)xmlNode; switch (xmlNodeElement.Name) { case "Project": solutionDescriptor.entryDescriptors.Add( ProjectDescriptor.CreateProjectDescriptor(xmlNodeElement, baseDirectory)); break; case "CombineEntry": case "SolutionItem": solutionDescriptor.entryDescriptors.Add( SolutionItemDescriptor.CreateDescriptor(addin, xmlNodeElement)); break; } } } return(solutionDescriptor); }
static IEnumerable <ISolutionItemDescriptor> GetItemsToCreate(SolutionDescriptor solutionDescriptor, ProjectCreateInformation cInfo) { foreach (ISolutionItemDescriptor descriptor in solutionDescriptor.EntryDescriptors) { var projectDescriptor = descriptor as ProjectDescriptor; if ((projectDescriptor != null) && !projectDescriptor.ShouldCreateProject(cInfo)) { // Skip. } else { yield return(descriptor); } } }
public static SolutionDescriptor CreateSolutionDescriptor (RuntimeAddin addin, XmlElement xmlElement, FilePath baseDirectory) { SolutionDescriptor solutionDescriptor = new SolutionDescriptor (); solutionDescriptor.addin = addin; if (xmlElement.Attributes["name"] != null) solutionDescriptor.name = xmlElement.Attributes["name"].Value; else throw new InvalidOperationException ("Attribute 'name' not found"); if (xmlElement.Attributes["type"] != null) solutionDescriptor.type = xmlElement.Attributes["type"].Value; if (xmlElement.Attributes["directory"] != null) solutionDescriptor.directory = xmlElement.Attributes["directory"].Value; if (xmlElement["Options"] != null && xmlElement["Options"]["StartupProject"] != null) solutionDescriptor.startupProject = xmlElement["Options"]["StartupProject"].InnerText; foreach (XmlNode xmlNode in xmlElement.ChildNodes) { if (xmlNode is XmlElement) { XmlElement xmlNodeElement = (XmlElement)xmlNode; switch (xmlNodeElement.Name) { case "Project": solutionDescriptor.entryDescriptors.Add ( ProjectDescriptor.CreateProjectDescriptor (xmlNodeElement, baseDirectory)); break; case "CombineEntry": case "SolutionItem": solutionDescriptor.entryDescriptors.Add ( SolutionItemDescriptor.CreateDescriptor (addin, xmlNodeElement)); break; } } } return solutionDescriptor; }
protected ProjectTemplate(RuntimeAddin addin, string id, ProjectTemplateCodon codon, string overrideLanguage) { XmlDocument xmlDocument = codon.GetTemplate(); XmlElement xmlConfiguration = xmlDocument.DocumentElement ["TemplateConfiguration"]; // Get legacy category. if (xmlConfiguration ["_Category"] != null) { category = xmlConfiguration ["_Category"].InnerText; } if (xmlConfiguration ["Category"] != null) { category = xmlConfiguration ["Category"].InnerText; } else if (category == null) { LoggingService.LogWarning(string.Format("Category missing in project template {0}", codon.Id)); } if (!string.IsNullOrEmpty(overrideLanguage)) { this.languagename = overrideLanguage; this.category = overrideLanguage + "/" + this.category; } else if (xmlConfiguration ["LanguageName"] != null) { List <string> listLanguages = new List <string> (); foreach (string item in xmlConfiguration["LanguageName"].InnerText.Split(',')) { listLanguages.Add(item.Trim()); } ExpandLanguageWildcards(listLanguages); this.languagename = listLanguages [0]; if (listLanguages.Count > 1 && !String.IsNullOrEmpty(languagename) && !category.StartsWith(languagename + "/")) { category = languagename + "/" + category; } for (int i = 1; i < listLanguages.Count; i++) { string language = listLanguages[i]; try { ProjectTemplates.Add(new ProjectTemplate(addin, id, codon, language)); } catch (Exception e) { LoggingService.LogError(GettextCatalog.GetString("Error loading template {0} for language {1}", codon.Id, language), e); } } } this.id = id; this.originator = xmlDocument.DocumentElement.GetAttribute("originator"); this.created = xmlDocument.DocumentElement.GetAttribute("created"); this.lastModified = xmlDocument.DocumentElement.GetAttribute("lastModified"); if (xmlConfiguration ["Wizard"] != null) { this.wizardPath = xmlConfiguration ["Wizard"].InnerText; } if (xmlConfiguration ["_Name"] != null) { this.nonLocalizedName = xmlConfiguration ["_Name"].InnerText; this.name = addin.Localizer.GetString(this.nonLocalizedName); } if (xmlConfiguration ["_Description"] != null) { this.description = addin.Localizer.GetString(xmlConfiguration ["_Description"].InnerText); } if (xmlConfiguration ["Icon"] != null) { this.icon = ImageService.GetStockId(addin, xmlConfiguration ["Icon"].InnerText, Gtk.IconSize.Dnd); } if (xmlConfiguration ["GroupId"] != null) { this.groupId = xmlConfiguration ["GroupId"].InnerText; this.condition = xmlConfiguration ["GroupId"].GetAttribute("condition"); } if (xmlConfiguration ["FileExtension"] != null) { this.fileExtension = xmlConfiguration ["FileExtension"].InnerText; } if (xmlConfiguration ["SupportedParameters"] != null) { this.supportedParameters = xmlConfiguration ["SupportedParameters"].InnerText; } if (xmlConfiguration ["DefaultParameters"] != null) { this.defaultParameters = xmlConfiguration ["DefaultParameters"].InnerText; } if (xmlConfiguration ["Image"] != null) { XmlElement imageElement = xmlConfiguration ["Image"]; imageId = imageElement.GetAttribute("id"); imageFile = imageElement.GetAttribute("file"); if (!String.IsNullOrEmpty(imageFile)) { imageFile = Path.Combine(codon.BaseDirectory, imageFile); } } if (xmlConfiguration ["Visibility"] != null) { visibility = xmlConfiguration ["Visibility"].InnerText; } if (xmlDocument.DocumentElement ["Combine"] == null) { throw new InvalidOperationException("Combine element not found"); } else { solutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor(addin, xmlDocument.DocumentElement ["Combine"], codon.BaseDirectory); } if (xmlDocument.DocumentElement ["Actions"] != null) { foreach (XmlNode xmlElement in xmlDocument.DocumentElement["Actions"]) { if (xmlElement is XmlElement && xmlElement.Attributes ["filename"] != null) { actions.Add(xmlElement.Attributes ["filename"].Value); } } } }
static IEnumerable<ISolutionItemDescriptor> GetItemsToCreate (SolutionDescriptor solutionDescriptor, ProjectCreateInformation cInfo) { foreach (ISolutionItemDescriptor descriptor in solutionDescriptor.EntryDescriptors) { var projectDescriptor = descriptor as ProjectDescriptor; if ((projectDescriptor != null) && !projectDescriptor.ShouldCreateProject (cInfo)) { // Skip. } else { yield return descriptor; } } }
protected ProjectTemplate (RuntimeAddin addin, string id, ProjectTemplateCodon codon, string overrideLanguage) { XmlDocument xmlDocument = codon.GetTemplate (); XmlElement xmlConfiguration = xmlDocument.DocumentElement ["TemplateConfiguration"]; // Get legacy category. if (xmlConfiguration ["_Category"] != null) { category = xmlConfiguration ["_Category"].InnerText; } if (xmlConfiguration ["Category"] != null) { category = xmlConfiguration ["Category"].InnerText; } else if (category == null) { LoggingService.LogWarning (string.Format ("Category missing in project template {0}", codon.Id)); } if (!string.IsNullOrEmpty (overrideLanguage)) { this.languagename = overrideLanguage; this.category = overrideLanguage + "/" + this.category; } else if (xmlConfiguration ["LanguageName"] != null) { List<string> listLanguages = new List<string> (); foreach (string item in xmlConfiguration ["LanguageName"].InnerText.Split (',')) listLanguages.Add (item.Trim ()); ExpandLanguageWildcards (listLanguages); this.languagename = listLanguages [0]; if (listLanguages.Count > 1 && !String.IsNullOrEmpty (languagename) && !category.StartsWith (languagename + "/")) category = languagename + "/" + category; for (int i = 1; i < listLanguages.Count; i++) { string language = listLanguages[i]; try { ProjectTemplates.Add (new ProjectTemplate (addin, id, codon, language)); } catch (Exception e) { LoggingService.LogError (GettextCatalog.GetString ("Error loading template {0} for language {1}", codon.Id, language), e); } } } this.id = id; this.originator = xmlDocument.DocumentElement.GetAttribute ("originator"); this.created = xmlDocument.DocumentElement.GetAttribute ("created"); this.lastModified = xmlDocument.DocumentElement.GetAttribute ("lastModified"); if (xmlConfiguration ["Wizard"] != null) { this.wizardPath = xmlConfiguration ["Wizard"].InnerText; } if (xmlConfiguration ["_Name"] != null) { this.nonLocalizedName = xmlConfiguration ["_Name"].InnerText; this.name = addin.Localizer.GetString (this.nonLocalizedName); } if (xmlConfiguration ["_Description"] != null) { this.description = addin.Localizer.GetString (xmlConfiguration ["_Description"].InnerText); } if (xmlConfiguration ["Icon"] != null) { this.icon = ImageService.GetStockId (addin, xmlConfiguration ["Icon"].InnerText, Gtk.IconSize.Dnd); } if (xmlConfiguration ["GroupId"] != null) { this.groupId = xmlConfiguration ["GroupId"].InnerText; this.condition = xmlConfiguration ["GroupId"].GetAttribute ("condition"); } if (xmlConfiguration ["FileExtension"] != null) { this.fileExtension = xmlConfiguration ["FileExtension"].InnerText; } if (xmlConfiguration ["SupportedParameters"] != null) { this.supportedParameters = xmlConfiguration ["SupportedParameters"].InnerText; } if (xmlConfiguration ["DefaultParameters"] != null) { this.defaultParameters = xmlConfiguration ["DefaultParameters"].InnerText; } if (xmlConfiguration ["Image"] != null) { XmlElement imageElement = xmlConfiguration ["Image"]; imageId = imageElement.GetAttribute ("id"); imageFile = imageElement.GetAttribute ("file"); if (!String.IsNullOrEmpty (imageFile)) { imageFile = Path.Combine (codon.BaseDirectory, imageFile); } } if (xmlConfiguration ["Visibility"] != null) { visibility = xmlConfiguration ["Visibility"].InnerText; } if (xmlDocument.DocumentElement ["Combine"] == null) { throw new InvalidOperationException ("Combine element not found"); } else { solutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor (addin, xmlDocument.DocumentElement ["Combine"], codon.BaseDirectory); } if (xmlDocument.DocumentElement ["Actions"] != null) { foreach (XmlNode xmlElement in xmlDocument.DocumentElement ["Actions"]) { if (xmlElement is XmlElement && xmlElement.Attributes ["filename"] != null) actions.Add (xmlElement.Attributes ["filename"].Value); } } }