Compartir a través de


TextTransformation.ClearIndent Method

Resets the CurrentIndent to an empty string.

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

Syntax

'Declaration
Public Sub ClearIndent
public void ClearIndent()
public:
void ClearIndent()
member ClearIndent : unit -> unit
public function ClearIndent()

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 how to call the ClearIndent method from a text template. Paste this code into any text template file and run the text template transformation to see the results.

<#
PushIndent("Indent1>  ");
PushIndent("Indent2>  ");
WriteLine("Test");

PushIndent("Indent3>  ");
PushIndent("Indent4>  ");
WriteLine("Test");

ClearIndent();

WriteLine("Test");
#>
<#
PushIndent("Indent1>  ")
PushIndent("Indent2>  ")
WriteLine("Test")

PushIndent("Indent3>  ")
PushIndent("Indent4>  ")
WriteLine("Test")

ClearIndent()

WriteLine("Test")
#>

This example produces the following output:

Indent1> Indent2> Test

Indent1> Indent2> Indent3> Indent4> Test

Test

.NET Framework Security

See Also

Reference

TextTransformation Class

Microsoft.VisualStudio.TextTemplating Namespace

CurrentIndent

PushIndent

PopIndent

Other Resources

Code Generation and T4 Text Templates