从模板生成多个输出文件 [英] Generating more than one output file from a template

查看:139
本文介绍了从模板生成多个输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在为我的xml文件编写一个自定义模板生成器.我想知道你们是否可以告诉我一种可以从同一模板下的模板生成多个输出文件的方法.

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.

文件数应取决于我输入的xml文件数

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

如果我想为a.xml生成c#类,我正在做类似的事情

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

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

我的函数XmlToCsGenerator.Xml(字符串路径)返回要写入文件的字符串.

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

预先感谢

推荐答案

Damien Guard的方法在此处详细介绍: http://damieng.com/blog/2009/11/06/t4的多重输出易于重新访问 也是一个好人.这与.Net 4.0产品中Entity Framework使用T4的方法非常接近.

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.

这篇关于从模板生成多个输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆