public TemplateEmitter(String templateName, Packages.VulcanPackage vulcanPackage, params string[] parameters) :base( vulcanPackage ) { this._template = vulcanPackage.TemplateManager[templateName]; this.SetParameters(parameters); }
public TemplateEmitter(Template template) : base(null) { this._template = template; if (template.MapDictionary.Keys.Count > 0) { this._templateParameters = new string[template.MapDictionary.Count]; } }
public void AddTemplateFile(string fileName) { XmlReaderSettings settings = new XmlReaderSettings(); settings.ValidationType = ValidationType.Schema; settings.Schemas = _templateSchemaSet; settings.ValidationEventHandler += new ValidationEventHandler(settings_ValidationEventHandler); XmlReader templateXmlReader = XmlReader.Create(fileName, settings); XmlDocument templateDocument = new XmlDocument(); templateDocument.Load(templateXmlReader); Message.Trace(Severity.Debug,"TemplateManager: Validating {0}", fileName); templateDocument.Validate(settings_ValidationEventHandler); Message.Trace(Severity.Debug,"TemplateManager: Validation Succeeded"); XPathNavigator templateNavigator = templateDocument.CreateNavigator(); XmlNamespaceManager templateNamespaceManager = new XmlNamespaceManager(templateNavigator.NameTable); templateNamespaceManager.AddNamespace("tm", "http://schemas.microsoft.com/detego/2007/07/07/VulcanTemplate.xsd"); foreach (XPathNavigator nav in templateNavigator.Select("//tm:Templates/tm:Template", templateNamespaceManager)) { string templateName = nav.SelectSingleNode("@Name").Value.Trim(); string templateData = nav.SelectSingleNode("tm:TemplateData", templateNamespaceManager).Value.Trim(); string templateType = nav.SelectSingleNode("@Type").Value.Trim(); Template t = new Template(templateName, templateType, templateData); Message.Trace(Severity.Debug,"Adding template " + templateName); if (templateType == "XMLTemplate") { Message.Trace(Severity.Debug,"{0} is an XML Template", templateName); } foreach (XPathNavigator mapNav in nav.Select("tm:Map", templateNamespaceManager)) { string source = mapNav.SelectSingleNode("@Source").Value; int index = mapNav.SelectSingleNode("@Index").ValueAsInt; Message.Trace(Severity.Debug,"Mapping input {0} to index {1}", source, index); t.MapDictionary.Add(source, index); } templateDictionary.Add(templateName, t); } }
public void AddTemplate(string templateName, Template template) { this.templateDictionary.Add(templateName, template); }