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
'Declaration
Public Function ProcessTemplate ( _
content As String, _
host As ITextTemplatingEngineHost _
) As String
'Usage
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.StringThe contents of the text template file to be transformed.
host
Type: Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHostThe 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.
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