Udostępnij za pośrednictwem


Metoda ITextTemplatingEngineHost.ResolveDirectiveProcessor —

Zwraca typ procesora w dyrektywie, biorąc pod uwagę jego przyjaznej nazwy.

Przestrzeń nazw:  Microsoft.VisualStudio.TextTemplating
Zestaw:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (w Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

Składnia

'Deklaracja
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

Parametry

  • processorName
    Typ: System.String
    Nazwa dyrektywa procesor być rozwiązane.

Wartość zwracana

Typ: System.Type
Type Dyrektywa procesora.

Uwagi

Silnik wywołania tej metody, na podstawie dyrektyw, podany przez użytkownika w szablonie tekstu.0, 1 Lub wiele razy dla każdego tekstu szablonu transformacji można wywołać tej metody.Aby uzyskać więcej informacji, zobacz T4 Tekst szablonu dyrektyw.

Jeśli nie można rozpoznać nazwy dyrektywa procesora, ta metoda powinien zgłosić wyjątek.

Jeśli mechanizm, który host używa, aby znaleźć dyrektywa procesora w metodzie ResolveDirectiveProcessor jest nie jest bezpieczne, złośliwy procesor dyrektywa może być uruchamiane.Złośliwy procesor dyrektywa może dostarczyć kod uruchomiony w trybie pełne zaufanie po uruchomieniu tego szablonu.Tworząc niestandardowe hosta, należy użyć bezpiecznego mechanizmu, takich jak rejestr, zlokalizować dyrektywa procesorów.Aby uzyskać więcej informacji, zobacz Zabezpieczenia szablonów tekstu.

Przykłady

Poniższy przykład kodu pokazuje możliwe wdrożenie niestandardowych hosta.Poniższy przykład kodu jest częścią większych przykład, w którym przewidziane jest ITextTemplatingEngineHost interfejsu.

Na przykład bardziej szczegółowe, która pokazuje, jak rozwiązać żądanie wygenerowane procesora w dyrektywie, zobacz Instruktaż: Podłączanie hostów do procesora wygenerowane dyrektywy.

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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

ITextTemplatingEngineHost Interfejs

Przestrzeń nazw Microsoft.VisualStudio.TextTemplating

ResolveAssemblyReference

ResolveFileName

Inne zasoby

Instruktaż: Tworzenie hosta szablon niestandardowy tekst

Zabezpieczenia szablonów tekstu