Bagikan melalui


Engine Class

The text template transformation engine.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.TextTemplating.Engine

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.10.0 (in Microsoft.VisualStudio.TextTemplating.10.0.dll)

Syntax

'Declaration
Public Class Engine _
    Implements ITextTemplatingEngine
public class Engine : ITextTemplatingEngine
public ref class Engine : ITextTemplatingEngine
type Engine =  
    class
        interface ITextTemplatingEngine
    end
public class Engine implements ITextTemplatingEngine

The Engine type exposes the following members.

Constructors

  Name Description
Public method Engine Initializes a new instance of the Engine class.

Top

Methods

  Name Description
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method PreprocessTemplate Generate code from a template which, when compiled and run, will produce the template output.
Public method ProcessTemplate Transforms the contents of a text template file to produce the generated text output.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Fields

  Name Description
Public fieldStatic member CacheAssembliesOptionString

Top

Remarks

The text template transformation process takes a text template file as the input, and produces a new text file as the output. The text template transformation engine component controls the process, and interacts with a text template transformation host and one or more text template directive processors to complete the process. For more information, see Code Generation and T4 Text Templates.

Tip

If you are writing a package or extension that will run within Visual Studio, consider using the text templating service, instead of writing your own host. For more information, see Invoking Text Transformation in a VS Extension.

Examples

The following example demonstrates how to create an instance of the Engine, and calling ProcessTemplate to transform a text template.

This code example is part of a larger example provided for the ITextTemplatingEngineHost interface.

Engine engine = new Engine();

//read the text template
string input = File.ReadAllText(templateFileName);

//transform the text template
string output = engine.ProcessTemplate(input, host);
Dim engine As Engine = New Engine()

'read the text template
Dim input As String = File.ReadAllText(templateFileName)

'transform the text template
Dim output As String = engine.ProcessTemplate(input, host)

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.TextTemplating Namespace

ITextTemplatingEngineHost

Other Resources

Processing Text Templates by using a Custom Host

Walkthrough: Creating a Custom Text Template Host

Code Generation and T4 Text Templates