T4输出到字符串 [英] T4 Output to String

查看:117
本文介绍了T4输出到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的T4,我想生成CRUD存储过程,数据访问层,输出到字符串,我想创建一种Web服务API的是有用的其他程序员也,只是输入的数据,以及下载的zip文件。

I am new to T4, I want to generate CRUD Stored Procedures, Data access layer, output to string, I am trying to create kind of webservice api to be useful to other programmers also, just input the data, and download zip file.

我寻觅了很多,但无法找到一个方法来生成输出字符串,它是可能的,任何文章,链接,一点code如果可能的话将是有益的。

I have searched a lot but could not find a way to generate output to string, is it possible, any articles, links, a bit of code if possible would be helpful.

是的,我们也可以使用StringBuilder的,但现在的问题是T4输出到字符串请所有类型的答案都是受欢迎的,但试图把重点放在这个问题。

Yes, we can also use StringBuilder, but The question is "T4 Output to String" please all type of answers are welcome, but try to focus on the question.

推荐答案

您可以使用的 preprocessed T4模板返回生成文件的字符串代替。

You can use preprocessed T4 templates to return a string instead of generating a file.

如果您更改自定义工具属性在Visual Studio中的文件为 TextTemplatingFile preprocessor ​​,然后在保存类将生成T4模板。这个类有一个返回生成的文本TransformText方法。

If you change the Custom Tools property on the file in Visual Studio to TextTemplatingFilePreprocessor then when you save the T4 template a class will be generated. This class will have a TransformText method which returns the generated text.

MSDN也有在运行时的文本生成与preprocessed T4模板。

这篇关于T4输出到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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