【问题标题】:What is purpose of T4 Generator in T4toolboxT4toolbox中T4 Generator的用途是什么
【发布时间】:2010-04-11 02:14:18
【问题描述】:

我正在使用 T4toolbox,我对生成器的用途感到困惑。我可以运行以下

public class Generator1 : Generator
{

    protected override void RunCore()
    {

        Template1 t = new Template1();
        t.Output.File = "t3.txt";
        t.Render();

    }
}

或者我可以像下面这样直接运行 t4 脚本。

Template1 t = new Template1();

t.Output.File = "t3.txt";

t.Render();

但我也可以使用没有生成器的 t4 脚本来做同样的事情。 所以我的意思是可以用两种方法“脚本-->生成器-->模板”和“脚本-->模板”做同样的事情,我错过了什么吗?

【问题讨论】:

  • 什么是 t4?你的代码看起来像 C#.. 我很困惑。
  • @Earlz:T4 是一个内置于 Visual Studio 2008+ 中的 .NET 代码生成器。 hanselman.com/blog/…

标签: t4 t4-toolbox


【解决方案1】:

Generator 类在想要封装多个模板时很有用。更多内容:http://www.olegsych.com/2008/09/t4-tutorial-creating-complex-code-generators/

【讨论】:

  • 看看 Oleg 提供的代码示例。它很好地演示了如何使用它们。
猜你喜欢
  • 2012-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-27
  • 2011-12-17
  • 2010-11-21
相关资源
最近更新 更多