다음을 통해 공유


ITextTemplatingEngineHost.LoadIncludeText 메서드

부분 텍스트 템플릿 파일을 포함하는 요청에 해당하는 텍스트를 가져옵니다.

네임스페이스:  Microsoft.VisualStudio.TextTemplating
어셈블리:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0(Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

구문

‘선언
Function LoadIncludeText ( _
    requestFileName As String, _
    <OutAttribute> ByRef content As String, _
    <OutAttribute> ByRef location As String _
) As Boolean
bool LoadIncludeText(
    string requestFileName,
    out string content,
    out string location
)
bool LoadIncludeText(
    String^ requestFileName, 
    [OutAttribute] String^% content, 
    [OutAttribute] String^% location
)
abstract LoadIncludeText : 
        requestFileName:string * 
        content:string byref * 
        location:string byref -> bool 
function LoadIncludeText(
    requestFileName : String, 
    content : String, 
    location : String
) : boolean

매개 변수

  • requestFileName
    형식: System.String
    가져올 부분 텍스트 템플릿 파일의 이름입니다.
  • content
    형식: System.String%
    가져온 텍스트가 포함된 String이거나, 파일을 찾을 수 없는 경우 Empty입니다.
  • location
    형식: System.String%
    가져온 텍스트의 위치가 포함된 String입니다.호스트는 레지스트리에서 포함 파일의 위치를 검색하거나 기본적으로 여러 위치를 검색하는 경우 포함 파일의 최종 경로를 이 매개 변수에 반환할 수 있습니다.호스트는 파일을 찾을 수 없거나 호스트가 파일 시스템 기반이 아닌 경우 location을 Empty로 설정할 수 있습니다.

반환 값

형식: System.Boolean
호스트가 텍스트를 가져올 수 있었으면 true이고, 그렇지 않으면 false입니다.

설명

텍스트 템플릿에서 선택적 include 지시문을 지정한 경우 엔진은 이 메서드를 호출합니다. 0, 1 또는 여러 번 각 변환에 대해 이 메서드를 호출할 수 있습니다. 자세한 내용은 T4 텍스트 템플릿 지시문을 참조하십시오.

사용자 지정 지시문 프로세서에서도 이 메서드를 호출할 수 있습니다.

예제

다음 코드 예제에서는 사용자 지정 호스트에 대한 가능한 구현을 보여 줍니다. 이 코드 예제는 보다 큰 예제의 일부입니다. 전체 예제를 보려면 연습: 사용자 지정 텍스트 템플릿 호스트 만들기을 참조하십시오.

public bool LoadIncludeText(string requestFileName, out string content, out string location)
{
    content = System.String.Empty;
    location = System.String.Empty;
    
    //If the argument is the fully qualified path of an existing file,
    //then we are done.
    //----------------------------------------------------------------
    if (File.Exists(requestFileName))
    {
        content = File.ReadAllText(requestFileName);
        return true;
    }

    //This can be customized to search specific paths for the file.
    //This can be customized to accept paths to search as command line
    //arguments.
    //----------------------------------------------------------------
    else
    {
        return false;
    }
}
Public Function LoadIncludeText(ByVal requestFileName As String, ByRef content As String, ByRef location As String) As Boolean Implements ITextTemplatingEngineHost.LoadIncludeText

    content = System.String.Empty
    location = System.String.Empty

    'If the argument is the fully qualified path of an existing file,
    'then we are done.
    '----------------------------------------------------------------
    If File.Exists(requestFileName) Then

        content = File.ReadAllText(requestFileName)
        Return True

    'This can be customized to search specific paths for the file.
    'This can be customized to accept paths to search as command line
    'arguments.
    '----------------------------------------------------------------
    Else
        Return False
    End If
End Function

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

ITextTemplatingEngineHost 인터페이스

Microsoft.VisualStudio.TextTemplating 네임스페이스

기타 리소스

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