Generating more than one output file from a templa

2019-05-20 06:38发布

Hi I am writing a custom template generator for my xml file. I was wondering if you guys can tell me a way I can generate more than one output file from the template under the same template.

The no of file should depend on the no of xml files I input

If I want to generate the c# class for a.xml I am doing something like this

<#= XmlToCsGenerator.Xml(this.Host.ResolvePath("a.xml")) #>

where my function XmlToCsGenerator.Xml(string path) returns the string to be written into the file.

Thanks in advance

2条回答
啃猪蹄的小仙女
2楼-- · 2019-05-20 07:17

Damien Guard's approach detailed here: http://damieng.com/blog/2009/11/06/multiple-outputs-from-t4-made-easy-revisited is a good one too. This is very close to the approach used in the Entity Framework's use of T4 in the .Net 4.0 product.

查看更多
Animai°情兽
3楼-- · 2019-05-20 07:26

Have a look at this article/sample:

http://www.olegsych.com/2008/09/t4-tutorial-creating-complex-code-generators/

Author has illustrated creating multiple delete procedures (corresponding to multiple tables) for single template.

查看更多
登录 后发表回答