T4 (Text Template Transformation Toolkit) is a code generator integrated on Visual Studio. Hmmm CodeSmith? ;-)Creating and editing a T4 Template
Steps * Add a Text File
* Rename with a .tt extension
* Write T4 template header configuration and template code
<#@ template language="C#v3.5" #>
<#@ import namespace = "System.Text.RegularExpressions" #>
<#@ output extension=".cs" #> <#
string lTitle = "MyHelloWorldClass";
#>namespace MyProject.Test
{
public class <#=lTitle #>
{
public <#=lTitle #>()
{
}
}
}Actually EF (Entity Framework) uses T4 to customize your EF generated classes.Tools
Tangible Engineering offer a T4 Editor (Free or Pro versions) to integrate on Visual Studio with intellisense. Read more: Refact your C# Code
Steps * Add a Text File
* Rename with a .tt extension
* Write T4 template header configuration and template code
<#@ template language="C#v3.5" #>
<#@ import namespace = "System.Text.RegularExpressions" #>
<#@ output extension=".cs" #> <#
string lTitle = "MyHelloWorldClass";
#>namespace MyProject.Test
{
public class <#=lTitle #>
{
public <#=lTitle #>()
{
}
}
}Actually EF (Entity Framework) uses T4 to customize your EF generated classes.Tools
Tangible Engineering offer a T4 Editor (Free or Pro versions) to integrate on Visual Studio with intellisense. Read more: Refact your C# Code
0 comments:
Post a Comment