逃脱Asp.Net MVC框架/枷锁,使用Razor视图引擎(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-20 07:53 点击:次
GeneratedClassContext =
new GeneratedClassContext("Execute", "Write", "WriteLiteral", "WriteTo",
"WriteLiteralTo",
"YourNameSpace.TemplateBase")
};
host.NamespaceImports.Add("System");
host.NamespaceImports.Add("YourNameSpaces");
//生成代码
CodeCompileUnit code;
using (var reader = new StringReader(template)) {
var generatedCode = new RazorTemplateEngine(host).GenerateCode(reader);
code = generatedCode.GeneratedCode;
}
//准备编译参数
var @params = new CompilerParameters
{
IncludeDebugInformation = false,
TempFiles = new TempFileCollection(AppDomain.CurrentDomain.DynamicDirectory),
CompilerOptions = "/target:library /optimize",
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>