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

混江龙づ霸主 提交于 2020-01-01 04:22:12

问题


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. In fact each file is for a specific country and the types come from country specific WSDL's.

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. How could I reduce the coding effort and write the logic at one place and get it generated for two different sets of types?


回答1:


or you could use the T4 Toolbox (Old CodePlex project, New GitHub project) and use the helpers to generate multiple files.

The author, Oleg Sych, has a documentary blog post (Archived version)

Or if you don't want this dependency just for this functionality, you can use the T4 file MultiOutput.tt (Archived version)



来源:https://stackoverflow.com/questions/4746161/how-to-use-t4-to-generate-two-files-at-the-same-time-from-one-template

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