コード例 #1
0
		public virtual object Create(object parent, object configContext, XmlNode section)
		{
			STViewEngineConfiguration config = new STViewEngineConfiguration();

			config.ConfigSection = section;

			XmlAttribute templateWriter = section.Attributes[ConfigConstants.ATTR_template_writer_type];
			if (templateWriter != null)
			{
				config.TemplateWriterTypeName = templateWriter.Value;
			}

			XmlAttribute templateLexer = section.Attributes[ConfigConstants.ATTR_template_lexer_type];
			if (templateLexer != null)
			{
				config.TemplateLexerTypeName = templateLexer.Value;
			}

			XmlNodeList renderers = section.SelectNodes(
				ConfigConstants.ELEMENT_attrib_renderers + "/" + ConfigConstants.ELEMENT_attrib_renderer
				);
			ProcessAttributeRenderers(renderers, config);

			Validate(config);

			return config;
		}
コード例 #2
0
        public virtual object Create(object parent, object configContext, XmlNode section)
        {
            STViewEngineConfiguration config = new STViewEngineConfiguration();

            config.ConfigSection = section;

            XmlAttribute templateWriter = section.Attributes[ConfigConstants.ATTR_template_writer_type];

            if (templateWriter != null)
            {
                config.TemplateWriterTypeName = templateWriter.Value;
            }

            XmlAttribute templateLexer = section.Attributes[ConfigConstants.ATTR_template_lexer_type];

            if (templateLexer != null)
            {
                config.TemplateLexerTypeName = templateLexer.Value;
            }

            XmlNodeList renderers = section.SelectNodes(
                ConfigConstants.ELEMENT_attrib_renderers + "/" + ConfigConstants.ELEMENT_attrib_renderer
                );

            ProcessAttributeRenderers(renderers, config);

            Validate(config);

            return(config);
        }
コード例 #3
0
        internal static STViewEngineConfiguration GetConfig(string sectionName)
        {
            STViewEngineConfiguration config = (STViewEngineConfiguration)
                                               ConfigurationSettings.GetConfig(sectionName);

            if (config == null)
            {
                return(new STViewEngineConfiguration());
            }
            return(config);
        }
コード例 #4
0
		private void ProcessAttributeRenderers(XmlNodeList renderers, STViewEngineConfiguration config)
		{
			foreach(XmlNode renderer in renderers)
			{
				string rendererTypeName = renderer.Attributes[ConfigConstants.ATTR_renderer_type].Value;
				string attributeTypeName = renderer.Attributes[ConfigConstants.ATTR_renderer_target_type].Value;
				XmlAttribute area = renderer.Attributes[ConfigConstants.ATTR_renderer_area];
				if (area == null)
                    config.RegisterAttributeRenderer(rendererTypeName, attributeTypeName);
				else
					config.RegisterAttributeRenderer(rendererTypeName, attributeTypeName, area.Value);
			}
		}
コード例 #5
0
 private void ProcessAttributeRenderers(XmlNodeList renderers, STViewEngineConfiguration config)
 {
     foreach (XmlNode renderer in renderers)
     {
         string       rendererTypeName  = renderer.Attributes[ConfigConstants.ATTR_renderer_type].Value;
         string       attributeTypeName = renderer.Attributes[ConfigConstants.ATTR_renderer_target_type].Value;
         XmlAttribute area = renderer.Attributes[ConfigConstants.ATTR_renderer_area];
         if (area == null)
         {
             config.RegisterAttributeRenderer(rendererTypeName, attributeTypeName);
         }
         else
         {
             config.RegisterAttributeRenderer(rendererTypeName, attributeTypeName, area.Value);
         }
     }
 }
コード例 #6
0
        protected void Validate(STViewEngineConfiguration config)
        {
            if (config.TemplateLexerTypeName != null)
            {
                ValidateTypeImplements(config.TemplateLexerTypeName, typeof(antlr.TokenStream));
            }

            if (config.TemplateWriterTypeName != null)
            {
                ValidateTypeImplements(config.TemplateWriterTypeName, typeof(Antlr.StringTemplate.IStringTemplateWriter));
            }

            foreach (string rendererTypeName in config.AllAttributeRenderers)
            {
                ValidateTypeImplements(rendererTypeName, typeof(Antlr.StringTemplate.IAttributeRenderer));
            }
        }
コード例 #7
0
 public IAttributeRenderer GetRendererInstance()
 {
     return((IAttributeRenderer)Activator.CreateInstance(STViewEngineConfiguration.GetType(rendererTypeName)));
 }
コード例 #8
0
		protected void Validate(STViewEngineConfiguration config)
		{
			if (config.TemplateLexerTypeName != null)
			{
				ValidateTypeImplements(config.TemplateLexerTypeName, typeof(antlr.TokenStream));
			}
			
			if (config.TemplateWriterTypeName != null)
			{
				ValidateTypeImplements(config.TemplateWriterTypeName, typeof(Antlr.StringTemplate.IStringTemplateWriter));
			}
			
			foreach(string rendererTypeName in config.AllAttributeRenderers)
			{
				ValidateTypeImplements(rendererTypeName, typeof(Antlr.StringTemplate.IAttributeRenderer));
			}
		}