27 июня 2008

T4 templates, Visual Studio 2008 & code generation

Domain-Specific Language Tools includes a text template transformation toolkit that supports the processing of text templates. A text template is a file that contains a mixture of text blocks and control logic. When you transform a text template, the control logic combines the text blocks with the data in a model to produce an output file. You can use text templates to create text artifacts such as code files and HTML reports. For example, a model of the flow of control between the individual pages in a user interface, such as a wizard, can be passed as input to a text template. The text template can generate code and configuration files that implement that flow of control.

All domain-specific language solutions include a debugging solution. The debugging solution is started whenever you press F5 or Ctrl+F5 from your domain-specific language solution. The debugging solution includes two sample text templates: one in Visual C# and one in Visual Basic.

The following are examples of tasks that you can perform by using text templates:

After creating models, you can iterate over their in-memory-representation (instead of their raw XML representation) to generate arbitrary text.

You can generate custom code by using either Visual C# or Visual Basic to navigate through a model.

You can generate custom reports in XML or HTML.

Про Т4:

Пример использования

Редактор http://www.t4editor.net/

Комментариев нет:

Архив блога

What to do?

you have site designed in a dark theme, saying dark background, white font.
By default google toolbar autocomplete cracks html for inputs or selects containg "email" "name" "address" and other buzzwords and changes background to yellow. As a result when visitor fills form, he enters text as white on yellow and can not easy validate his input
What to do?



item http://www.voronenko.com/2008/06/t4-templates-visual-studio-2008-code.html