模板配置
Inheritance: ConfigBase
Beispiel #1
0
        /// <summary>
        /// 引擎配置
        /// </summary>
        /// <param name="conf">配置内容</param>
        /// <param name="ctx">默认模板上下文</param>
        public static void Configure(EngineConfig conf, TemplateContext ctx)
        {
            if (conf == null)
            {
                throw new ArgumentNullException("conf");
            }

            if (conf.TagParsers == null)
            {
                conf.TagParsers = conf.TagParsers = Field.RSEOLVER_TYPES;
            }
            _context = ctx;
            ITagParser[] parsers = new ITagParser[conf.TagParsers.Length];

            for (Int32 i = 0; i < conf.TagParsers.Length; i++)
            {
                parsers[i] = (ITagParser)Activator.CreateInstance(Type.GetType(conf.TagParsers[i]));
            }

            ICache cache = null;
            if (!string.IsNullOrEmpty(conf.CachingProvider))
            {
                cache = (ICache)Activator.CreateInstance(Type.GetType(conf.CachingProvider));
            }

            Parser.TagTypeResolver resolver = new Parser.TagTypeResolver(parsers);
            _engineRuntime = new Runtime(resolver,
                cache,
                conf);
        }
Beispiel #2
0
 /// <summary>
 /// 创建默认配置
 /// </summary>
 /// <returns></returns>
 public static EngineConfig CreateDefault()
 {
     EngineConfig conf = new EngineConfig();
     conf.CachingProvider = null;
     conf.ResourceDirectories = new String[0];
     conf.StripWhiteSpace = true;
     conf.TagFlag = '$';
     conf.TagPrefix = "${";
     conf.TagSuffix = "}";
     conf.ThrowExceptions = true;
     conf.IgnoreCase = true;
     conf.TagParsers = Field.RSEOLVER_TYPES;
     return conf;
 }
Beispiel #3
0
 /// <summary>
 /// 创建默认配置
 /// </summary>
 /// <returns></returns>
 public static EngineConfig CreateDefault()
 {
     EngineConfig conf = new EngineConfig();
     //conf.CachingProvider = "JinianNet.JNTemplate.Caching.MemoryCache";
     conf.ResourceDirectories = new String[0];
     conf.StripWhiteSpace = true;
     conf.TagFlag = '$';
     conf.TagPrefix = "${";
     conf.TagSuffix = "}";
     conf.ThrowExceptions = true;
     conf.IgnoreCase = true;
     conf.TagParsers = Field.RSEOLVER_TYPES;
     conf.Charset = "utf-8";
     return conf;
 }
Beispiel #4
0
 /// <summary>
 /// 引擎配置
 /// </summary>
 /// <param name="conf">配置内容</param>
 public static void Configure(EngineConfig conf)
 {
     Configure(conf, null);
 }