다음을 통해 공유


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 텍스트 템플릿 지시문을 참조하십시오.

지시문 프로세서 이름을 확인할 수 없으면 이 메서드는 예외를 throw해야 합니다.

호스트가 메서드 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(String)

기타 리소스

연습: 사용자 지정 텍스트 템플릿 호스트 만들기

텍스트 템플릿 보안