CodeSmith是一款不错的.Net开发辅助工具,可以使工作效率得到很大提高。最近用它做了一项目,其中要自动保存多个文件。上网查了查,能查到的都是用继承Inherits="OutputFileCodeTemplate" 方法来实现,个人觉得这方法过于麻烦。后来查了查CodeSmith 4.1的联机帮助,里面讲得很清楚,用子模版的RenderToFile就可以了,原文如下:
CodeSmith用子模版的RenderToFile输出到指定文件 This technique is useful for generating multiple identical copies of the same file. When you need to generate multiple different files as part of a single code-generation process, you should use one sub-template for each file. Call the sub-templates from a master template and use the RenderToFile method to output each sub-template.
以下是我写的Demo,很简单吧:
 1CodeSmith用子模版的RenderToFile输出到指定文件public void RenderMyAspxCs(TableSchema table,string strTableName,string nameSpaceStr) 
 2

相关文章:

  • 2021-08-30
  • 2021-10-05
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-01-22
猜你喜欢
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-10-08
  • 2021-09-06
  • 2021-09-16
相关资源
相似解决方案