private void LoadTemplate(string templatePath, bool parseTemplate) { if (string.IsNullOrEmpty(templatePath) || !File.Exists(templatePath)) { throw new ArgumentException("The template specified is invalid or could not be found", "templatePath"); } // save the template path this._templatePath = templatePath; // check for a cached version of this template if (templateCache != null && (_parseList = templateCache.Get(templatePath)) != null) { return; } string templateContent = File.ReadAllText(_templatePath); string templateFolder = Path.GetDirectoryName(_templatePath); templateContent = templateParser.PreProcessTemplate(templateContent, templateFolder); // parse the template ready for running _parseList = templateParser.ParseTemplate(templateContent); // check if we need to cache this template if (templateCache != null && _parseList != null) { templateCache.Add(templatePath, _parseList); } }
public virtual TemplateCompileResult CompileTemplate(string template) { var parseContext = parser.ParseTemplate(template); if (debugOutput != null) { GenerateDebugInfo(parseContext.CodeCompileUnit); } var assembly = GenerateAssembly(parseContext); return(new TemplateCompileResult { CompiledAssembly = assembly, Namespace = parseContext.Namespace, Class = parseContext.Class, }); }