1 Star 0 Fork 0

月冷贇 / SJNScaffolding

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

SJNScaffolding

ABP代码生成器

本项目使用RazorEngine模板引擎技术,对于熟悉razor语法的开发者来说是非常容易的。

这里提供最简单的一个栗子。

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变量

avatar

解决了模板生成,我们就很容易的写出自己的代码生成器。

空文件

简介

ABP代码生成器 展开 收起
CSS
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
CSS
1
https://gitee.com/try119/SJNScaffolding.git
git@gitee.com:try119/SJNScaffolding.git
try119
SJNScaffolding
SJNScaffolding
master

搜索帮助