TextTransformation.ClearIndent 方法

CurrentIndent 重設為空字串。

命名空間:  Microsoft.VisualStudio.TextTemplating
組件:  Microsoft.VisualStudio.TextTemplating.10.0 (在 Microsoft.VisualStudio.TextTemplating.10.0.dll 中)

語法

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

備註

CurrentIndent 代表在所產生的文字輸出中每一行的前置文字。 縮排文字只能是空格,例如 "    ",或者可以包含字組。 PushIndent 會將文字加入至 CurrentIndent,並可被呼叫多次。 PopIndent 會自 CurrentIndent 移除最近加入且可呼叫多次的文字。 從 CurrentIndent 會移除 ClearIndent 中的所有文字。

範例

下列程式碼範例示範如何從文字範本呼叫 ClearIndent 方法。 將這個程式碼貼到任何文字範本檔案,並執行文字範本轉換,以查看結果。

<#
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")
#>

這個範例會產生下列輸出:

Indent1> Indent2> Test

Indent1> Indent2> Indent3> Indent4> Test

Test

.NET Framework 安全性

請參閱

參考

TextTransformation 類別

Microsoft.VisualStudio.TextTemplating 命名空間

CurrentIndent

PushIndent

PopIndent

其他資源

程式碼產生和 T4 文字範本