关于T4:Text Template Transformation Toolkit - TOMMYHU - 专注互联网开发及运营技术,提供相关资料及软件下载,奇趣网络时事评论!
Oct 14

关于T4:Text Template Transformation Toolkit 不指定

tommyhu , 20:56 , ASP.NET , Comments(1) , Trackbacks(0) , Reads(7372) , Via Original Large | Medium | Small

 对代码生成工具感兴趣的朋友,一定熟悉CodeSmith那种ASP.NET语法的模板驱动的生成模式吧,而Text Template Transformation Toolkit (T4) 就是微软的一个非常类似的代码生成引擎,可以用来生成任何基于文本的文件。

Text Template Transformation Toolkit已经被包含到Visual Studio2008里面,你不应对此感到奇怪,因为Visual Studio的代码模板就是基于Text Template Transformation Toolkit的,在Visual Studio2008里,当你往项目中添加一个后缀为".tt"的文件后,Visual Studio会自动将Text Template Transformation Toolkit分配为此文件的custom tool并生成输出文件,这和Visual Studio基于".xsd"文件生成强类型程序集的机制是一样的。

而对于Visual Studio2005,你也可以从对应附加的DSLGAT工具下载到Text Template Transformation Toolkit

Text Template Transformation Toolkit的生成原理大致如下图所示:

 

T4ProcessHorizontal_thumb2

诸位有对基于Text Template Transformation Toolkit做代码生成感兴趣的,Oleg SychText Template Transformation Toolkit一定要拜读。

Madhavrao从MSDN上搜集的一堆链接也是肯定用得着的:

Calling Directives

        
  1. How to: Call a Generated Directive
  2.     
  3. How to: Call a Custom Directive

Basic Text Template Task

        
  1. How to: Create Text Template
  2.     
  3. How to: Open Text Template for Editing
  4.     
  5. How to: Run Text Template

Using Built-In Directives in Text Template

        
  1. How to: Specify File Output Types in Text Templates
  2.     
  3. How to: Specify a Language in Text Templates
  4.     
  5. How to: Specify a culture in Text Templates
  6.     
  7. How to: Reference Assembly in Text Templates
  8.     
  9. How to: Import Namespace in Text Templates
  10.     
  11. How to: Include files in Text Templates
  12.     
  13. How to: Split Text Templates Into Multiple Files

Adding Code to Text Template

        
  1. How to: Add statement to Text Template
  2.     
  3. How to: Add an Expression to Text Template
  4.     
  5. How to: Add Helper function to Text Template
  6.     
  7. How to: Generate Errors and Warnings from Text Template
  8.     
  9. How to: Append Text to the Generated Text

Generating specific type of artifact from Text Template

        
  1. How to: Generate HTML from Text Template
  2.     
  3. How to: Generate Code from Text Template
  4.     
  5. How to: Use Escape sequences in Text Template
  6.     
  7. How to: Generate templates from templates using Escape Sequences

Creating Custom Text Template Directive Processors

        
  1. How to: Create Custom Directive Processors
  2.     
  3. How to: Set Registry keys for Custom Directive Processors

Creating Custom Text Template Host

        
  1. How to: Create Custom Text Template Host

Troubleshooting Text Templates

        
  1. How to: Debug Text Templates

▲返回顶部

Pages: 1/1 First page 1 Final page
Add a comment

Nickname

emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot