public FileTemplate(AddIn addin, string filename) { Stream stream = addin.GetResourceStream (filename); if (stream == null) throw new ApplicationException ("Template " + filename + " not found"); XmlDocument doc = new XmlDocument(); try { doc.Load(stream); } finally { stream.Close (); } XmlElement config = doc.DocumentElement["TemplateConfiguration"]; originator = doc.DocumentElement.Attributes["Originator"].InnerText; created = doc.DocumentElement.Attributes["Created"].InnerText; lastmodified = doc.DocumentElement.Attributes["LastModified"].InnerText; name = GettextCatalog.GetString (config["_Name"].InnerText); category = config["Category"].InnerText; languagename = config["LanguageName"].InnerText; if (config["_Description"] != null) { description = GettextCatalog.GetString (config["_Description"].InnerText); } if (config["Icon"] != null) { icon = ResourceService.GetStockId (addin, config["Icon"].InnerText); } if (config["Wizard"] != null) { wizardpath = config["Wizard"].Attributes["path"].InnerText; } fileoptions = doc.DocumentElement["FileOptions"]; // load the files XmlElement files = doc.DocumentElement["TemplateFiles"]; XmlNodeList nodes = files.ChildNodes; foreach (XmlElement filenode in nodes) { FileDescriptionTemplate template = new FileDescriptionTemplate(filenode.Attributes["DefaultName"].InnerText + filenode.Attributes["DefaultExtension"].InnerText, filenode.InnerText); this.files.Add(template); } }
protected ProjectTemplate(AddIn addin, string fileName) { Stream stream = addin.GetResourceStream (fileName); if (stream == null) throw new ApplicationException ("Template " + fileName + " not found"); XmlDocument doc = new XmlDocument(); try { doc.Load(stream); } finally { stream.Close (); } originator = doc.DocumentElement.Attributes["originator"].InnerText; created = doc.DocumentElement.Attributes["created"].InnerText; lastmodified = doc.DocumentElement.Attributes["lastModified"].InnerText; XmlElement config = doc.DocumentElement["TemplateConfiguration"]; if (config["Wizard"] != null) { wizardpath = config["Wizard"].InnerText; } name = GettextCatalog.GetString (config["_Name"].InnerText); category = config["Category"].InnerText; if (config["LanguageName"] != null) languagename = config["LanguageName"].InnerText; if (config["_Description"] != null) { description = GettextCatalog.GetString (config["_Description"].InnerText); } if (config["Icon"] != null) { icon = ResourceService.GetStockId (addin, config["Icon"].InnerText); } if (doc.DocumentElement["Combine"] != null) { combineDescriptor = CombineDescriptor.CreateCombineDescriptor(doc.DocumentElement["Combine"]); } // Read Actions; if (doc.DocumentElement["Actions"] != null) { foreach (XmlElement el in doc.DocumentElement["Actions"]) { actions.Add(new OpenFileAction(el.Attributes["filename"].InnerText)); } } }