RequiresProvidesDirectiveProcessor.GeneratePostInitializationCode 메서드

파생 클래스에서 재정의되는 경우 생성된 변환 클래스의 초기화 코드에 코드를 추가합니다. 이 코드는 기본 클래스가 초기화된 후에 추가됩니다.

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

구문

‘선언
Protected MustOverride Sub GeneratePostInitializationCode ( _
    directiveName As String, _
    codeBuffer As StringBuilder, _
    languageProvider As CodeDomProvider, _
    requiresArguments As IDictionary(Of String, String), _
    providesArguments As IDictionary(Of String, String) _
)
protected abstract void GeneratePostInitializationCode(
    string directiveName,
    StringBuilder codeBuffer,
    CodeDomProvider languageProvider,
    IDictionary<string, string> requiresArguments,
    IDictionary<string, string> providesArguments
)
protected:
virtual void GeneratePostInitializationCode(
    String^ directiveName, 
    StringBuilder^ codeBuffer, 
    CodeDomProvider^ languageProvider, 
    IDictionary<String^, String^>^ requiresArguments, 
    IDictionary<String^, String^>^ providesArguments
) abstract
abstract GeneratePostInitializationCode : 
        directiveName:string * 
        codeBuffer:StringBuilder * 
        languageProvider:CodeDomProvider * 
        requiresArguments:IDictionary<string, string> * 
        providesArguments:IDictionary<string, string> -> unit 
protected abstract function GeneratePostInitializationCode(
    directiveName : String, 
    codeBuffer : StringBuilder, 
    languageProvider : CodeDomProvider, 
    requiresArguments : IDictionary<String, String>, 
    providesArguments : IDictionary<String, String>
)

매개 변수

  • codeBuffer
    형식: System.Text.StringBuilder
    기본 클래스가 처리 실행 중에 초기화된 후에 모든 지시문 프로세서가 실행해야 하는 코드를 연결하는 버퍼입니다.기본 클래스가 초기화된 후에 이 지시문 프로세서가 이 지시문에 대해 실행해야 하는 모든 코드가 이 버퍼에 연결되어야 합니다.

설명

GenerateTransformCode는 생성된 변환 클래스에 메서드를 추가할 수 있기 때문에 이러한 메서드를 호출하려면 초기화 코드가 종종 필요합니다.

이 메서드는 이 프로세서를 처리하는각 지시문에 대해 한 번씩 호출됩니다. 따라서 각 지시문에 대한 코드를 codeBuffer에 추가할 수 있습니다. GetPostInitializationCodeForProcessingRun은 모든 지시문이 처리된 후 codeBuffer의 내용을 반환합니다.

이 메서드는 ProcessDirective에 의해 호출됩니다.

예제

이 예제에서는 기본 클래스를 초기화한 후 코드를 생성합니다. 이 예제는 RequiresProvidesDirectiveProcessor 클래스에 대한 보다 큰 예제의 일부입니다.

protected override void GeneratePostInitializationCode(string directiveName, StringBuilder codeBuffer, System.CodeDom.Compiler.CodeDomProvider languageProvider, IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments)
{
if (StringComparer.InvariantCultureIgnoreCase.Compare(directiveName, DomDirectiveTag) == 0)
{
// Resolve the file name of the specified "requires" xml file
// This allows the xml file to be a path relative to the text template that is using the directive processor.
string xmlFile = this.Host.ResolvePath(requiresArguments[XmlFileRequiredParameterName]);
if (!File.Exists(xmlFile))
{
throw new FileNotFoundException("Unable to load " + XmlFileRequiredParameterName, xmlFile);
}

string fieldName = providesArguments[DomProvidedParameterName].ToLower(CultureInfo.InvariantCulture) + "Value";

// Write code to initialize the domValue field by loading the xml file.
// The property is named "Dom" by default but the template writer may have changed the name using a custom provides clause like 'provides="Dom=AnotherName"'
codeBuffer.Append(
"this." + fieldName + " = new XmlDocument();" +
"this." + fieldName + ".Load(@\"" + xmlFile + "\");");
}
}

.NET Framework 보안

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

참고 항목

참조

RequiresProvidesDirectiveProcessor 클래스

Microsoft.VisualStudio.TextTemplating 네임스페이스

GeneratePreInitializationCode

GenerateTransformCode

ProcessDirective

GetPostInitializationCodeForProcessingRun