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 命名空间

其他资源

演练:创建自定义文本模板宿主