简体   繁体   English

如何使用T4从一个模板同时生成两个文件?

[英]How to use T4 to generate two files at the same time from one template?

I am having a case in which I need to generate two CSharp code files with pretty the same code but different namespace of the input and output types of the methods. 我有一个案例,我需要生成两个CSharp代码文件具有相同的代码但不同的方法的输入和输出类型的命名空间。 In fact each file is for a specific country and the types come from country specific WSDL's. 实际上,每个文件都针对特定国家/地区,而且类型来自特定国家/地区的WSDL。

I am writing some wrappers around the services and the logic is exactly the same but the types automatically generated from WSDL's are different. 我正在围绕服务编写一些包装器,逻辑完全相同,但是从WSDL自动生成的类型是不同的。 How could I reduce the coding effort and write the logic at one place and get it generated for two different sets of types? 我怎样才能减少编码工作量并在一个地方编写逻辑并为两组不同类型生成逻辑?

or you could use the T4 Toolbox ( Old CodePlex project , New GitHub project ) and use the helpers to generate multiple files. 或者您可以使用T4工具箱旧CodePlex项目New GitHub项目 )并使用帮助程序生成多个文件。

The author, Oleg Sych, has a documentary blog post ( Archived version ) 作者Oleg Sych有一篇纪录片博客文章存档版

Or if you don't want this dependency just for this functionality, you can use the T4 file MultiOutput.tt ( Archived version ) 或者,如果您不希望此依赖项仅用于此功能,则可以使用T4文件MultiOutput.tt存档版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM