Generating more than one output file from a template

倾然丶 夕夏残阳落幕 提交于 2019-12-10 11:17: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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4755240/generating-more-than-one-output-file-from-a-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!