示例#1
0
 public TemplateEmitter(Template template)
 {
     this._template = template;
     if (template.MapDictionary.Keys.Count > 0)
     {
         this._templateParameters = new string[template.MapDictionary.Count];
     }
 }
示例#2
0
        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);

            MessageEngine.Global.Trace(Severity.Debug, "TemplateManager: Validating {0}", fileName);
            templateDocument.Validate(settings_ValidationEventHandler);
            MessageEngine.Global.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);
                MessageEngine.Global.Trace(Severity.Debug, "Adding template " + templateName);

                if (templateType == "XMLTemplate")
                {
                    MessageEngine.Global.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;
                    MessageEngine.Global.Trace(Severity.Debug, "Mapping input {0} to index {1}", source, index);
                    t.MapDictionary.Add(source, index);
                }

                templateDictionary.Add(templateName, t);
            }
        }
示例#3
0
 public void AddTemplate(string templateName, Template template)
 {
     this.templateDictionary.Add(templateName, template);
 }