Export (0) Print
Expand All

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)

[<CLSCompliantAttribute(true)>]
type ITextTemplatingEngineHost =  interface end

The ITextTemplatingEngineHost type exposes the following members.

  NameDescription
Public propertyStandardAssemblyReferencesGets a list of assembly references.
Public propertyStandardImportsGets a list of namespaces.
Public propertyTemplateFileGets the path and file name of the text template that is being processed.
Top

  NameDescription
Public methodGetHostOptionCalled by the Engine to ask for the value of a specified option. Return null if you do not know.
Public methodLoadIncludeTextAcquires the text that corresponds to a request to include a partial text template file.
Public methodLogErrorsReceives a collection of errors and warnings from the transformation engine.
Public methodProvideTemplatingAppDomainProvides an application domain to run the generated transformation class.
Public methodResolveAssemblyReferenceAllows a host to provide additional information about the location of an assembly.
Public methodResolveDirectiveProcessorReturns the type of a directive processor, given its friendly name.
Public methodResolveParameterValueResolves the value of a parameter for a directive processor if the parameter is not specified in the template text.
Public methodResolvePathAllows a host to provide a complete path, given a file name or relative path.
Public methodSetFileExtensionTells the host the file name extension that is expected for the generated text output.
Public methodSetOutputEncodingTells the host the encoding that is expected for the generated text output.
Top

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.

Show:
© 2014 Microsoft