Export (0) Print
Expand All

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.12.0 (in Microsoft.VisualStudio.TextTemplating.12.0.dll)

public string ProcessTemplate(
	string content,
	ITextTemplatingEngineHost host
)

Parameters

content
Type: System.String

The contents of the text template file to be transformed.

host
Type: 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)

ExceptionCondition
ArgumentNullException

content is null.

-or-

host is null.

In Visual Studio, if a file has its Custom Tool property set to TextTemplatingFileGenerator, 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 and Processing Text Templates by using a Custom Host.

TipTip

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.

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);

Show:
© 2014 Microsoft