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.10.0 (in Microsoft.VisualStudio.TextTemplating.10.0.dll)
Syntax
'Declaration
Public Function ProcessTemplate ( _
content As String, _
host As ITextTemplatingEngineHost _
) As String
public string ProcessTemplate(
string content,
ITextTemplatingEngineHost host
)
public:
virtual String^ ProcessTemplate(
String^ content,
ITextTemplatingEngineHost^ host
) sealed
abstract ProcessTemplate :
content:string *
host:ITextTemplatingEngineHost -> string
override ProcessTemplate :
content:string *
host:ITextTemplatingEngineHost -> string
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
Exception | Condition |
---|---|
ArgumentNullException | content is nulla null reference (Nothing in Visual Basic). -or- host is nulla 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 and Processing Text Templates by using a Custom Host.
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)
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualStudio.TextTemplating Namespace