diff --git a/.template.config/Blog.Core.Webapi.Template.1.11.30.nupkg b/.template.config/Blog.Core.Webapi.Template.1.11.30.nupkg index cb281b2..6cd56c9 100644 Binary files a/.template.config/Blog.Core.Webapi.Template.1.11.30.nupkg and b/.template.config/Blog.Core.Webapi.Template.1.11.30.nupkg differ diff --git a/Blog.Core.FrameWork/DbHelper.ttinclude b/Blog.Core.FrameWork/DbHelper.ttinclude index 37780b4..ad450e9 100644 --- a/Blog.Core.FrameWork/DbHelper.ttinclude +++ b/Blog.Core.FrameWork/DbHelper.ttinclude @@ -167,60 +167,33 @@ } #region DbTable - /// - /// 表结构 - /// public sealed class DbTable { - /// - /// 表名称 - /// public string TableName { get; set; } - /// - /// 表的架构 - /// public string SchemaName { get; set; } - /// - /// 表的记录数 - /// public int Rows { get; set; } - /// - /// 是否含有主键 - /// public bool HasPrimaryKey { get; set; } } #endregion #region DbColumn - /// - /// 表字段结构 - /// + public sealed class DbColumn { - /// - /// 字段ID - /// + public int ColumnID { get; set; } - /// - /// 是否主键 - /// + public bool IsPrimaryKey { get; set; } - /// - /// 字段名称 - /// + public string ColumnName { get; set; } - /// - /// 字段类型 - /// + public string ColumnType { get; set; } - /// - /// 数据库类型对应的C#类型 - /// + public string CSharpType { get @@ -240,36 +213,17 @@ } } - /// - /// 字节长度 - /// public int ByteLength { get; set; } - /// - /// 字符长度 - /// public int CharLength { get; set; } - ///精度长度 public int Precision{get;set;} - /// - /// 小数位 - /// public int Scale { get; set; } - /// - /// 是否自增列 - /// public bool IsIdentity { get; set; } - /// - /// 是否允许空 - /// public bool IsNullable { get; set; } - /// - /// 描述 - /// public string Remark { get; set; } } #endregion diff --git a/Blog.Core.FrameWork/ModelAuto.ttinclude b/Blog.Core.FrameWork/ModelAuto.ttinclude index ead4578..5933972 100644 --- a/Blog.Core.FrameWork/ModelAuto.ttinclude +++ b/Blog.Core.FrameWork/ModelAuto.ttinclude @@ -5,10 +5,8 @@ <#@ import namespace="System.Text"#> <#@ import namespace="Microsoft.VisualStudio.TextTemplating"#> <#+ -//定义管理者 manager 实体类 class Manager { - //定义一个 block 块,主要是应用在批量生产中 public struct Block { public int Start, Length; public String Name,OutputPath; @@ -21,13 +19,11 @@ class Manager public ITextTemplatingEngineHost host; public ManagementStrategy strategy; public StringBuilder template; - //构造函数,包含 host主机,模板,输出路径,创建管理策略 public Manager(ITextTemplatingEngineHost host, StringBuilder template, bool commonHeader) { this.host = host; this.template = template; strategy = ManagementStrategy.Create(host); } - //开辟一个 block 块 public void StartBlock(String name,String outputPath) { currentBlock = new Block { Name = name, Start = template.Length ,OutputPath=outputPath}; } @@ -52,13 +48,11 @@ class Manager currentBlock.Length = template.Length - currentBlock.Start; blocks.Add(currentBlock); } - //定义进程,用来将所有的 blocks 块执行出来 public void Process(bool split) { String header = template.ToString(headerBlock.Start, headerBlock.Length); String footer = template.ToString(footerBlock.Start, footerBlock.Length); blocks.Reverse(); - foreach(Block block in blocks) {//遍历 - //输出文件 + foreach(Block block in blocks) { String fileName = Path.Combine(block.OutputPath, block.Name); if (split) { String content = header + template.ToString(block.Start, block.Length) + footer; @@ -70,7 +64,6 @@ class Manager } } } -//定义管理策略类 class ManagementStrategy { internal static ManagementStrategy Create(ITextTemplatingEngineHost host) { @@ -104,16 +97,13 @@ class VSManagementStrategy : ManagementStrategy templateProjectItem = dte.Solution.FindProjectItem(host.TemplateFile); } - //创建文件 internal override void CreateFile(String fileName, String content) { base.CreateFile(fileName, content); //((EventHandler)delegate { templateProjectItem.ProjectItems.AddFromFile(fileName); }).BeginInvoke(null, null, null, null); } - //删除文件 internal override void DeleteFile(String fileName) { ((EventHandler)delegate { FindAndDeleteFile(fileName); }).BeginInvoke(null, null, null, null); } - //根据文件名删除文件 private void FindAndDeleteFile(String fileName) { foreach(EnvDTE.ProjectItem projectItem in templateProjectItem.ProjectItems) { if (projectItem.get_FileNames(0) == fileName) {