Engine.ProcessTemplate Method

Transforms the contents of a text template file to produce the generated text output.

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

Syntax

'宣言
Public Function ProcessTemplate ( _
    content As String, _
    host As ITextTemplatingEngineHost _
) As String
'使用
Dim instance As Engine
Dim content As String
Dim host As ITextTemplatingEngineHost
Dim returnValue As String

returnValue = instance.ProcessTemplate(content, _
    host)
public string ProcessTemplate(
    string content,
    ITextTemplatingEngineHost host
)
public:
virtual String^ ProcessTemplate(
    String^ content, 
    ITextTemplatingEngineHost^ host
) sealed
public final function ProcessTemplate(
    content : String, 
    host : ITextTemplatingEngineHost
) : String

Parameters

  • content
    Type: System.String

    The contents of the text template file to be transformed.

Return Value

Type: System.String

The generated text output of the text template file.

Implements

ITextTemplatingEngine.ProcessTemplate(String, ITextTemplatingEngineHost)

Exceptions

Exception Condition
ArgumentNullException

content is a null reference (Nothing in Visual Basic).

-or-

host is a null reference (Nothing in Visual Basic).

Remarks

In Visual Studio, if a file has its Custom Tool property set to TextTemplatingFileGenerator, then clicking Run Custom Tool in the user interface corresponds to calling ProcessTemplate to transform the template.

For more information, see How to: Create Text Templates.

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)

Permissions

See Also

Concepts

About Text Template Hosts

Walkthrough: Creating a Custom Text Template Host

Reference

Engine Class

Engine Members

Microsoft.VisualStudio.TextTemplating Namespace

ITextTemplatingEngineHost

ArgumentNullException

ProcessTemplate