共用方式為


TextTransformation.CurrentIndent 屬性

取得目前縮排文字,這個文字是每行所產生之文字輸出都有前置文字。

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

語法

'宣告
Public ReadOnly Property CurrentIndent As String
public string CurrentIndent { get; }
public:
property String^ CurrentIndent {
    String^ get ();
}
member CurrentIndent : string
function get CurrentIndent () : String

屬性值

型別:System.String
String ,包含每行所產生之文字輸出都有的前置文字。

備註

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

範例

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

<#
PushIndent("Indent: ");

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

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

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

ClearIndent()
#>

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

Indent: Test

Indent: Indent:

Indent: 8

.NET Framework 安全性

請參閱

參考

TextTransformation 類別

Microsoft.VisualStudio.TextTemplating 命名空間

PushIndent

PopIndent

ClearIndent

其他資源

程式碼產生和 T4 文字範本