Share via


ITextTemplatingEngineHost.ResolveParameterValue 方法

如果範本文字中未指定參數,則解析指示詞處理器的參數值。

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

語法

'宣告
Function ResolveParameterValue ( _
    directiveId As String, _
    processorName As String, _
    parameterName As String _
) As String
string ResolveParameterValue(
    string directiveId,
    string processorName,
    string parameterName
)
String^ ResolveParameterValue(
    String^ directiveId, 
    String^ processorName, 
    String^ parameterName
)
abstract ResolveParameterValue : 
        directiveId:string * 
        processorName:string * 
        parameterName:string -> string 
function ResolveParameterValue(
    directiveId : String, 
    processorName : String, 
    parameterName : String
) : String

參數

  • directiveId
    型別:System.String
    參數所屬之指示詞呼叫的 ID。這個 ID 可讓相同文字範本對相同指示詞的每個重複呼叫有所區分。
  • processorName
    型別:System.String
    指示詞所屬之指示詞處理器的名稱。
  • parameterName
    型別:System.String
    要解析之參數的名稱。

傳回值

型別:System.String
String ,表示已解析的參數值。

備註

這個方法可以由指示詞處理器,或是從文字範本的程式碼呼叫,以取得文字範本主應用程式中的值。指示詞處理器通常會呼叫此方法以取得指示詞參數的預設值。

例如,在於命令列公用程式 TextTransform.exe 執行的主機中,此方法會從–a命令列選項擷取值。如需詳細資訊,請參閱 使用 TextTransform 公用程式產生檔案

範例

下列程式碼範例示範自訂主機可能的實作。這個程式碼是完整範例的一部分。如需完整的範例,請參閱 逐步解說:建立自訂文字範本主機

public string ResolveParameterValue(string directiveId, string processorName, string parameterName)
{
    if (directiveId == null)
    {
        throw new ArgumentNullException("the directiveId cannot be null");
    }
    if (processorName == null)
    {
        throw new ArgumentNullException("the processorName cannot be null");
    }
    if (parameterName == null)
    {
        throw new ArgumentNullException("the parameterName cannot be null");
    }

    //code to provide "hard-coded" parameter values goes here
    //this code depends on the directive processors this host will interact with

    //if we cannot do better - return the empty string
    return String.Empty;
}
Public Function ResolveParameterValue(ByVal directiveId As String, ByVal processorName As String, ByVal parameterName As String) As String Implements Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveParameterValue

    If directiveId Is Nothing Then
        Throw New ArgumentNullException("the directiveId cannot be null")
    End If
    If processorName Is Nothing Then
        Throw New ArgumentNullException("the processorName cannot be null")
    End If
    If parameterName Is Nothing Then
        Throw New ArgumentNullException("the parameterName cannot be null")
    End If

    'code to provide "hard-coded" parameter values goes here
    'this code depends on the directive processors this host will interact with

    'if we cannot do better - return the empty string
    Return String.Empty
End Function

.NET Framework 安全性

請參閱

參考

ITextTemplatingEngineHost 介面

Microsoft.VisualStudio.TextTemplating 命名空間

其他資源

逐步解說:建立自訂文字範本主機