2.2. Text Template Transformation Toolkit Files

A Text Template Transformation Toolkit (T4) template is a code-generation language that has been around since VS2005. You should be aware of T4 templates, as they are used in areas such as Entity Framework and ASP.NET MVC, and can be useful for your own development. To see T4 templates in action, create a file with the extension .tt, add some text content, save the file, and note how Visual Studio will generate a code file from the template. You can apply complex logic using T4 templating language to change the output that is generated depending on various conditions.

T4 templates in VS2010 are compiled when they are saved (preprocessed). This means that they are another type that can be instantiated.

Scott Hanselman has some great and information on this area, so please refer to the following article:

www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKept
VisualStudioSecret.aspx.

T4 templates don't have IntelliSense, so your best bet is to download the Tangible T4 plug-in: http://visualstudiogallery.msdn.microsoft.com/en-us/60297607-5fd4-4da4-97e1-3715e90c1a23.

For more information, see http://code.msdn.microsoft.com/DslTools/Wiki/View.aspx?title=What%27s%20new and http://karlshifflett.wordpress.com/2009/10/30/t4-preprocessed-text-templates-in-visual-studio-2010/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.27.171