protected StringTemplateGroup GetTemplateManager(Controller controller) { if ((controller.AreaName == null) || (controller.AreaName.Trim().Length == 0)) { return(templateGroup); } StringTemplateGroup group = (StringTemplateGroup)area2templateManager[controller.AreaName]; if (group == null) { group = new BasicStringTemplateGroup( ConfigConstants.STGROUP_NAME_PREFIX + "_area_" + controller.AreaName, (StringTemplateLoader)null, config.TemplateLexerType); group.SuperGroup = templateGroup; if (config.TemplateWriterTypeName != null) { group.SetTemplateWriterType(config.TemplateWriterType); } IEnumerator renderersEnumerator = config.GetAttributeRenderersForArea(controller.AreaName); while (renderersEnumerator.MoveNext()) { RendererInfo rendererInfo = (RendererInfo)renderersEnumerator.Current; group.RegisterAttributeRenderer(rendererInfo.AttributeType, rendererInfo.GetRendererInstance()); } area2templateManager[controller.AreaName] = group; } return(group); }
public void Initialize() { config = STViewEngineConfiguration.GetConfig(ConfigConstants.ELEMENT_stview_sectionname); StringTemplateGroup componentGroup = new ViewComponentStringTemplateGroup( ConfigConstants.STGROUP_NAME_PREFIX + "_components", config.TemplateLexerType); StringTemplateGroup helpersSTGroup = new BasicStringTemplateGroup( ConfigConstants.STGROUP_NAME_PREFIX + "_helpersST", new EmbeddedResourceTemplateLoader(this.GetType().Assembly, ConfigConstants.HELPER_RESOURCE_NAMESPACE, false), config.TemplateLexerType); helpersSTGroup.SuperGroup = componentGroup; templateGroup = new BasicStringTemplateGroup( ConfigConstants.STGROUP_NAME_PREFIX, new FileSystemTemplateLoader(ViewSourceLoader.ViewRootDir, false), config.TemplateLexerType); templateGroup.SuperGroup = helpersSTGroup; if (config.TemplateWriterTypeName != null) { componentGroup.SetTemplateWriterType(config.TemplateWriterType); helpersSTGroup.SetTemplateWriterType(config.TemplateWriterType); templateGroup.SetTemplateWriterType(config.TemplateWriterType); } IEnumerator globalRenderersEnumerator = config.GetGlobalAttributeRenderers(); while (globalRenderersEnumerator.MoveNext()) { RendererInfo renderInfo = (RendererInfo)globalRenderersEnumerator.Current; componentGroup.RegisterAttributeRenderer(renderInfo.AttributeType, renderInfo.GetRendererInstance()); helpersSTGroup.RegisterAttributeRenderer(renderInfo.AttributeType, renderInfo.GetRendererInstance()); templateGroup.RegisterAttributeRenderer(renderInfo.AttributeType, renderInfo.GetRendererInstance()); } }
protected StringTemplateGroup GetTemplateManager(Controller controller) { if ((controller.AreaName == null) || (controller.AreaName.Trim().Length == 0)) return templateGroup; StringTemplateGroup group = (StringTemplateGroup)area2templateManager[controller.AreaName]; if (group == null) { group = new BasicStringTemplateGroup( ConfigConstants.STGROUP_NAME_PREFIX + "_area_" + controller.AreaName, (StringTemplateLoader)null, config.TemplateLexerType); group.SuperGroup = templateGroup; if (config.TemplateWriterTypeName != null) { group.SetTemplateWriterType(config.TemplateWriterType); } IEnumerator renderersEnumerator = config.GetAttributeRenderersForArea(controller.AreaName); while (renderersEnumerator.MoveNext()) { RendererInfo rendererInfo = (RendererInfo)renderersEnumerator.Current; group.RegisterAttributeRenderer(rendererInfo.AttributeType, rendererInfo.GetRendererInstance()); } area2templateManager[controller.AreaName] = group; } return group; }