TextTransformation.CurrentIndent Property

Gets the current indent text, which is prefixed to each line of the generated text output.

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

Syntax

'宣言
Public ReadOnly Property CurrentIndent As String
'使用
Dim instance As TextTransformation
Dim value As String

value = instance.CurrentIndent
public string CurrentIndent { get; }
public:
property String^ CurrentIndent {
    String^ get ();
}
public function get CurrentIndent () : String

Property Value

Type: System.String

A String that contains the text that is prefixed to each line of the generated text output.

Remarks

The CurrentIndent represents text that is prefixed to each line of the generated text output. The indent text can be spaces only, for example "    ", or it can include words. PushIndent adds text to CurrentIndent, and can be called more then once. PopIndent removes the most recently added text from CurrentIndent, and can be called more than once. ClearIndent removes all text from the CurrentIndent.

Examples

The following code example demonstrates calling the CurrentIndent property from a text template. Paste this code into any text template file and run the text template transformation to see the results.

<#
PushIndent("Indent: ");

WriteLine("Test");
WriteLine(CurrentIndent);
WriteLine(CurrentIndent.Length.ToString());

ClearIndent();
#>
<#
PushIndent("Indent: ")

WriteLine("Test")
WriteLine(CurrentIndent)
WriteLine(CurrentIndent.Length.ToString())

ClearIndent()
#>

This example produces the following output:

Indent: Test

Indent: Indent:

Indent: 8

Permissions

See Also

Concepts

Generating Artifacts Using Text Templates

Reference

TextTransformation Class

TextTransformation Members

Microsoft.VisualStudio.TextTemplating Namespace

PushIndent

PopIndent

ClearIndent