Domain-Specific Language Tools Reference
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

Visual Basic (Declaration)
Public Function ProcessTemplate ( _
    content As String, _
    host As ITextTemplatingEngineHost _
) As String
Visual Basic (Usage)
Dim instance As Engine
Dim content As String
Dim host As ITextTemplatingEngineHost
Dim returnValue As String

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

Parameters

content
Type: System..::.String

The contents of the text template file to be transformed.

host
Type: Microsoft.VisualStudio.TextTemplating..::.ITextTemplatingEngineHost

The ITextTemplatingEngineHost that will host this engine.

Return Value

Type: System..::.String

The generated text output of the text template file.

Implements

ITextTemplatingEngine..::.ProcessTemplate(String, ITextTemplatingEngineHost)
Exceptions

ExceptionCondition
ArgumentNullException

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

-or-

host is nullNothingnullptra 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.

C#
Engine engine = new Engine();

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

//transform the text template
string output = engine.ProcessTemplate(input, host);
Visual Basic
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

Reference

Tag :


Page view tracker