Udostępnij za pośrednictwem


ITextTemplatingComponents.Host Property

Get the singleton Vs Host

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

Syntax

'Declaration
ReadOnly Property Host As ITextTemplatingEngineHost
ITextTemplatingEngineHost Host { get; }
property ITextTemplatingEngineHost^ Host {
    ITextTemplatingEngineHost^ get ();
}
abstract Host : ITextTemplatingEngineHost
function get Host () : ITextTemplatingEngineHost

Property Value

Type: Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost

Remarks

You can use this object if you want to process text templates in a separate instance of the text templating Engine. The Engine will then process the templates in the same way as they are processed by the parent service. For example, if you get the components of the Visual Studio text templating service, errors will be reported on the Visual Studio Error window.

You can set the InputFile and Hierarchy properties for each template to be transformed before each call to engine.ProcessTemplate.

Examples

using Microsoft.VisualStudio.TextTemplating;
using Microsoft.VisualStudio.TextTemplating.VSHost;
...
// Get the main Visual Studio text templating service.
// Notice that we cast to ITextTemplatingComponents instead of ITextTemplating:
ITextTemplatingComponents ttc = serviceProvider.GetService(typeof(STextTemplating)) as ITextTemplatingComponents;

// Create my own templating engine instance:
Engine engine = new Engine();

// Set processing parameters:
ttc.InputFile = "myTemplateFile";

// Process the result using the main VS host:
string result = engine.ProcessTemplate(myTemplateContent, ttc.Host);
// Any errors in myTemplateContent will appear in the VS error window.
// Any error reports will use the filename "myTemplateFile".

.NET Framework Security

See Also

Reference

ITextTemplatingComponents Interface

Microsoft.VisualStudio.TextTemplating.VSHost Namespace