开发者

Generating more than one output file from a template

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 n开发者_C百科o 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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜