ITextTemplatingEngineHost.ResolveDirectiveProcessor メソッド

指定された表示名のディレクティブ プロセッサの型を返します。

名前空間:  Microsoft.VisualStudio.TextTemplating
アセンブリ:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll 内)

構文

'宣言
Function ResolveDirectiveProcessor ( _
    processorName As String _
) As Type
Type ResolveDirectiveProcessor(
    string processorName
)
Type^ ResolveDirectiveProcessor(
    String^ processorName
)
abstract ResolveDirectiveProcessor : 
        processorName:string -> Type 
function ResolveDirectiveProcessor(
    processorName : String
) : Type

パラメーター

  • processorName
    型 : System.String
    解決するディレクティブ プロセッサの名前。

戻り値

型 : System.Type
ディレクティブ プロセッサの Type

解説

ユーザーがテキスト テンプレートで指定したディレクティブに基づいて、エンジンはこのメソッドを呼び出します。このメソッドは、テキスト テンプレートの変換ごとに 0 回、1 回、または複数回呼び出すことができます。詳細については、「T4 テキスト テンプレートのディレクティブ」を参照してください。

ディレクティブ プロセッサ名を解決できない場合、このメソッドは例外をスローする必要があります。

ホストが ResolveDirectiveProcessor メソッドでディレクティブ プロセッサを見つけるために使用する機構がセキュリティで保護されていない場合は、悪意のあるディレクティブ プロセッサを実行することができます。悪意のあるディレクティブ プロセッサは、テンプレートを実行するとき、完全信頼モードで実行されるコードを提供できます。カスタム ホストを作成する場合は、レジストリなど、セキュリティで保護されたメカニズムを使用してディレクティブ プロセッサを検索する必要があります。詳細については、「テキスト テンプレートのセキュリティ」を参照してください。

カスタム ホストを実装するコード例を次に示します。このコード例は ITextTemplatingEngineHost インターフェイスのトピックで取り上げている例の一部分です。

生成されたディレクティブ プロセッサに対する要求を解決する方法を示す詳細な例については、「チュートリアル: 生成済みディレクティブ プロセッサへのホストの接続」を参照してください。

public Type ResolveDirectiveProcessor(string processorName)
{
    //this host will not resolve any specific processors

    //check the processor name, and if it is the name of a processor the 
    //host wants to support, return the type of the processor
    //---------------------------------------------------------------------
    if (string.Compare(processorName, "XYZ", StringComparison.OrdinalIgnoreCase) == 0)
    {
        //return typeof();
    }

    //this can be customized to search specific paths for the file,
    //or to search the GAC

    //if the directive processor can not be found, throw an error
    throw new Exception("Directive Processor not found");
}
Public Function ResolveDirectiveProcessor(ByVal processorName As String) As System.Type Implements Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveDirectiveProcessor
    'this host will not resolve any specific processors

    'check the processor name, and if it is the name of a processor the 
    'host wants to support, return the type of the processor
    '---------------------------------------------------------------------
    If String.Compare(processorName, "XYZ", StringComparison.OrdinalIgnoreCase) = 0 Then
        'return typeof()
    End If

    'this can be customized to search specific paths for the file,
    'or to search the GAC

    'if the directive processor can not be found, throw an error
    Throw New Exception("Directive Processor not found")
End Function

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

ITextTemplatingEngineHost インターフェイス

Microsoft.VisualStudio.TextTemplating 名前空間

ResolveAssemblyReference

ResolveFileName

その他の技術情報

チュートリアル: カスタム テキスト テンプレート ホストの作成

テキスト テンプレートのセキュリティ