T4, or Text Template Transformation Toolkit, is the free code generation engine from Microsoft that is now included in Visual Studio 2008 and and available as a download for Visual Studio 2005 in DSL and GAT toolkits. You can use T4 templates to generate Visual Basic, C#, T-SQL, XML or any other text files.
Here are some articles from Oleg Sych on how the technology can be used...
Text Template Transformation Toolkit
http://www.olegsych.com/2007/12/text-template-transformation-toolkit/
How to create a simple T4 template
http://www.olegsych.com/2007/12/how-to-create-a-simple-t4-template/
How to use T4 to generate .config files
http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-config-files/
How to use T4 to generate Decorator classes
http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-decorator-classes/
How to use T4 to generate CRUD stored procedures
http://www.olegsych.com/2008/01/how-to-use-t4-to-generate-crud-stored-procedures/
T4 as a general-purpose .NET scripting engine
http://www.olegsych.com/2008/02/t4-as-a-general-purpose-net-scripting-engine/
How to generate multiple outputs from single T4 template
http://www.olegsych.com/2008/03/how-to-generate-multiple-outputs-from-single-t4-template/
Below is a great video by Hilton Giesenow on how it could possibly be used...
http://msdn2.microsoft.com/en-gb/vstudio/cc308634.aspx
Learn about the Text Templating Transformation Toolkit (T4), the code generation engine used as part of Domain Specific Languages and Software Factories projects. With the T4 toolkit now built directly into Visual Studio 2008, you can easily add code generation to your arsenal. Hilton Giesenow demonstrates how