ITextTemplatingEngineHost.SetFileExtension Method
Tells the host the file name extension 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 SetFileExtension ( _
extension As String _
)
void SetFileExtension(
string extension
)
void SetFileExtension(
String^ extension
)
abstract SetFileExtension :
extension:string -> unit
function SetFileExtension(
extension : String
)
Parameters
- extension
Type: System.String
The file name extension for the generated text output.
Remarks
If the user has specified the optional output parameter of the template directive in a text template, the engine calls this method. 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.
//the host can provide a default by setting the value of the field here
private string fileExtensionValue = ".txt";
public string FileExtension
{
get { return fileExtensionValue; }
}
public void SetFileExtension(string extension)
{
//the parameter extension has a '.' in front of it already
//--------------------------------------------------------
fileExtensionValue = extension;
}
'the host can provide a default by setting the value of the field here
Private fileExtensionValue As String = ".txt"
Public ReadOnly Property FileExtension() As String
Get
Return fileExtensionValue
End Get
End Property
Public Sub SetFileExtension(ByVal extension As String) Implements Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.SetFileExtension
'the parameter extension has a '.' in front of it already
'--------------------------------------------------------
fileExtensionValue = extension
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