代码拉取完成,页面将自动刷新
ABP代码生成器
这里提供最简单的一个栗子。
demo1
CopyRightTemplate.cshtml模板代码如下
@model SJNScaffolding.Models.TemplateModels.CopyRightUserInfo
//=============================================================
// 创建人: @Model.UserName
// 创建时间: @Model.CreateTime
// 邮箱: @Model.EmailAddress
//==============================================================
对应的实体类
public class CopyRightUserInfo
{
public string UserName { get; set; }
public string EmailAddress { get; set; }
public DateTime CreateTime { get; set; }
public string FileRemark { get; set; }
}
对应的test方法
//根据路径。要根据自己实际情况调整
private const string BasePath = @"..\..\..\SJNScaffolding\";
[TestMethod]
public void testCorpyRight()
{
var path = BasePath + "Templates\\CopyRightTemplate.cshtml";
var template = File.ReadAllText(path);
string content = Engine.Razor.RunCompile(template, "CopyRightTemplate", typeof(CopyRightUserInfo), new CopyRightUserInfo
{
CreateTime = DateTime.Now,
EmailAddress = "710277267@qq.com",
UserName = "IGeekFan"
});
}
下断点后运行,content变量
解决了模板生成,我们就很容易的写出自己的代码生成器。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。