Export (0) Print
Expand All

ITextTemplatingEngineHost.SetOutputEncoding Method

Tells the host the encoding that is expected for the generated text output.

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

void SetOutputEncoding(
	Encoding encoding,
	bool fromOutputDirective
)

Parameters

encoding
Type: System.Text.Encoding
The encoding for the generated text output.
fromOutputDirective
Type: System.Boolean
true to indicate that the user specified the encoding in the encoding parameter of the output directive.

The engine calls this method if the user has specified the optional encoding parameter of the template directive in a text template. For more information, see T4 Text Template Directives.

The following code example shows a possible implementation for a custom host. This code example is part of a larger example. For the complete example, see Walkthrough: Creating a Custom Text Template Host.

private Encoding fileEncodingValue = Encoding.UTF8;
public Encoding FileEncoding
{
    get { return fileEncodingValue; }
}

public void SetOutputEncoding(System.Text.Encoding encoding, bool fromOutputDirective)
{
    fileEncodingValue = encoding;
}

Community Additions

ADD
Show:
© 2014 Microsoft