Share via


ITextTemplatingEngineHost Interface

The interface for the host that transforms text templates. This is available to directive processors and can also be accessed by text templates.

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

Syntax

'Declaration
<CLSCompliantAttribute(True)> _
Public Interface ITextTemplatingEngineHost
[CLSCompliantAttribute(true)]
public interface ITextTemplatingEngineHost
[CLSCompliantAttribute(true)]
public interface class ITextTemplatingEngineHost
[<CLSCompliantAttribute(true)>]
type ITextTemplatingEngineHost =  interface end
public interface ITextTemplatingEngineHost

The ITextTemplatingEngineHost type exposes the following members.

Properties

  Name Description
Public property StandardAssemblyReferences Gets a list of assembly references.
Public property StandardImports Gets a list of namespaces.
Public property TemplateFile Gets the path and file name of the text template that is being processed.

Top

Methods

  Name Description
Public method GetHostOption Called by the Engine to ask for the value of a specified option. Return null if you do not know.
Public method LoadIncludeText Acquires the text that corresponds to a request to include a partial text template file.
Public method LogErrors Receives a collection of errors and warnings from the transformation engine.
Public method ProvideTemplatingAppDomain Provides an application domain to run the generated transformation class.
Public method ResolveAssemblyReference Allows a host to provide additional information about the location of an assembly.
Public method ResolveDirectiveProcessor Returns the type of a directive processor, given its friendly name.
Public method ResolveParameterValue Resolves the value of a parameter for a directive processor if the parameter is not specified in the template text.
Public method ResolvePath Allows a host to provide a complete path, given a file name or relative path.
Public method SetFileExtension Tells the host the file name extension that is expected for the generated text output.
Public method SetOutputEncoding Tells the host the encoding that is expected for the generated text output.

Top

Remarks

A host takes a text template file as the input and produces a text file as output. A typical host is the TextTemplatingFileGenerator tool that transforms templates in a Visual Studio project. It calls one or more directive processors to deal with different types of template. The members of this interface are accessible to the directive processors, and to the code of the text template. The text template engine controls this process and interacts with a host and one or more directive processors. To learn more about these components, see Code Generation and T4 Text Templates.

To make the host accessible to the code of a text template, set the hostspecific parameter of the template directive. For example:

<#@template language="c#" hostspecific="true" #>
<# // This template is specific to the TextTemplatingFileGenerator host,
   // which transforms templates in a Visual Studio project. #>
These are the projects in this solution:
<#=this.Host.ResolveParameterValue("-", "-", "projects") #>

If you want to use text templates outside Visual Studio or with custom tools, you can write a custom host, implementing this interface. For an example, see Walkthrough: Creating a Custom Text Template 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.

See Also

Reference

Microsoft.VisualStudio.TextTemplating Namespace

Other Resources

Walkthrough: Creating a Custom Text Template Host

Code Generation and T4 Text Templates