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)
Syntax
'Declaration
Sub SetOutputEncoding ( _
encoding As Encoding, _
fromOutputDirective As Boolean _
)
void SetOutputEncoding(
Encoding encoding,
bool fromOutputDirective
)
void SetOutputEncoding(
Encoding^ encoding,
bool fromOutputDirective
)
abstract SetOutputEncoding :
encoding:Encoding *
fromOutputDirective:bool -> unit
function SetOutputEncoding(
encoding : Encoding,
fromOutputDirective : boolean
)
Parameters
encoding
Type: EncodingThe encoding for the generated text output.
fromOutputDirective
Type: Booleantrue to indicate that the user specified the encoding in the encoding parameter of the output directive.
Remarks
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.
Examples
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;
}
Private fileEncodingValue As Encoding = Encoding.UTF8
Public ReadOnly Property fileEncoding() As Encoding
Get
Return fileEncodingValue
End Get
End Property
Public Sub SetOutputEncoding(ByVal encoding As System.Text.Encoding, ByVal fromOutputDirective As Boolean) Implements ITextTemplatingEngineHost.SetOutputEncoding
fileEncodingValue = encoding
End Sub
.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
ITextTemplatingEngineHost Interface
Microsoft.VisualStudio.TextTemplating Namespace