Aracılığıyla paylaş


RequiresProvidesDirectiveProcessor.GeneratePostInitializationCode Yöntem

Türetilmiş bir sınıfta geçersiz kılınmış, kod oluşturulan dönüştürme sınıf başlatma kodunu ekler.Temel sınıf başlatıldıktan sonra bu kodu eklenir.

Ad alanı:  Microsoft.VisualStudio.TextTemplating
Derleme:  Microsoft.VisualStudio.TextTemplating.11.0 (Microsoft.VisualStudio.TextTemplating.11.0.dll içinde)

Sözdizimi

'Bildirim
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>
)

Parametreler

  • codeBuffer
    Tür: System.Text.StringBuilder
    Yönergesi tüm işlemcilerin Temel sınıftan sonra çalıştırılmalıdır kod birleştirir arabellek çalıştırma işlemi sırasında başlatılır.Temel sınıf başlatıldıktan sonra bu yönergenin işlemci Bu yönerge için çalıştırmanız gereken kod bu arabelleğe birleştirilmiş.

Notlar

Çünkü GenerateTransformCode yöntemleri ekleyebilirsiniz oluşturulan dönüştürme sınıfına başlatma kodu genellikle bu yöntemleri çağırmak için gereklidir.

Bu yöntem bu işlemcinin işler her yönerge için bir kez denir.Bu nedenle, her yönerge kodu ekleme codeBuffer.GetPostInitializationCodeForProcessingRuniçeriğini döndürür codeBuffer tüm emirleri işlendikten sonra.

Bu yöntem çaðrýlýr ProcessDirective.

Örnekler

Temel sınıf başlatıldıktan sonra bu örnek kodu oluşturur.Bu örnek için büyük bir örnek bir parçası olan RequiresProvidesDirectiveProcessor sınıfı.

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 Güvenliği

Ayrıca bkz.

Başvuru

RequiresProvidesDirectiveProcessor Sınıf

Microsoft.VisualStudio.TextTemplating Ad Alanı

GeneratePreInitializationCode

GenerateTransformCode

ProcessDirective

GetPostInitializationCodeForProcessingRun