Generating Code Using Text Template Transformation Toolkit (T4)
Many times
developers come across situations where they need to write similar code
over and over again. Automating the generation of such boilerplate code
not only reduces the time spent but also reduces the chances of errors
while doing such monotonous development. To help developers achieve this
goal, Visual Studio 2010 includes what is known as Text Template
Transformation Toolkit (T4). T4 templates are text files that specify
the structure of the code or markup to produce. T4 comes with its own
set of directives and blocks, which allow you to you define the
boilerplate for code generation. This article introduces you to T4
basics and familiarizes you with the various parts of a T4 template.
http://www.bipinjoshi.net/articles/3c5d9520-4c11-4a9f-a020-261b36e1f48b.aspx