2

I am using T4toolbox, I am confused what the generator is for. I can run the following

public class Generator1 : Generator
{

    protected override void RunCore()
    {

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

    }
}

or I can run t4 script directly like the following.

Template1 t = new Template1();

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

t.Render();

But I can do the same using t4 script without generator as well. So I mean can do the same thing with two approach "script --> generator --> template" and "script --> template", am I missing something?

Michael Maddox
  • 12,331
  • 5
  • 38
  • 40
Fred Yang
  • 2,521
  • 3
  • 21
  • 29
  • What is t4? Your code looks like C#.. I'm confused. – Earlz Apr 08 '10 at 14:26
  • @Earlz: T4 is a code generator for .NET built into Visual Studio 2008+. http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx – Michael Maddox Apr 10 '10 at 18:07

1 Answers1

3

Generator class is useful when want to encapsulate multiple templates. More here: http://www.olegsych.com/2008/09/t4-tutorial-creating-complex-code-generators/

Oleg Sych
  • 6,548
  • 36
  • 34
  • Take a look at the code examples Oleg provides as well. It demonstrates pretty well how to use them. – Brian Oct 20 '12 at 19:42