/// <summary> /// 默认配置 /// </summary> public Config(Char flag, String prefix, String suffix) { this.paths = new System.Collections.ObjectModel.Collection <String>(); this.resolver = new Parser.TagTypeResolver(); this.resolver.Add(new BooleanParser()); this.resolver.Add(new NumberParser()); this.resolver.Add(new EleseParser()); this.resolver.Add(new EndParser()); this.resolver.Add(new VariableParser()); this.resolver.Add(new StringParser()); this.resolver.Add(new ForeachParser()); this.resolver.Add(new ForParser()); this.resolver.Add(new SetParser()); this.resolver.Add(new IfParser()); this.resolver.Add(new ElseifParser()); this.resolver.Add(new LoadParser()); this.resolver.Add(new IncludeParser()); this.resolver.Add(new FunctionParser()); this.resolver.Add(new ComplexParser()); this.cachingProvider = null; this.tagFlag = flag; this.tagSuffix = suffix; this.tagPrefix = prefix; this.throwExceptions = false; }
/// <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); }