Metoda RequiresProvidesDirectiveProcessor.GeneratePostInitializationCode —
Gdy zastąpiony w klasie pochodnej, dodaje kod do kodu inicjowania klasy generowane transformacji.Ten kod jest dodawany po klasy podstawowej jest zainicjowany.
Przestrzeń nazw: Microsoft.VisualStudio.TextTemplating
Zestaw: Microsoft.VisualStudio.TextTemplating.11.0 (w Microsoft.VisualStudio.TextTemplating.11.0.dll)
Składnia
'Deklaracja
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>
)
Parametry
- directiveName
Typ: System.String
Nazwa tej dyrektywy.
- codeBuffer
Typ: System.Text.StringBuilder
Bufor, który łączy kod, który wszystkie procesory w dyrektywie, należy uruchomić po klasy podstawowej jest inicjowany podczas przetwarzania, uruchom.Każdy kod, który po klasy podstawowej jest inicjowany do celów niniejszej dyrektywy musi uruchomić ten procesor dyrektywa powinna zostać dołączona do tego buforu.
- languageProvider
Typ: System.CodeDom.Compiler.CodeDomProvider
Generator kodu, który tworzy kod, aby dodać do codeBuffer.
- requiresArguments
Typ: System.Collections.Generic.IDictionary<String, String>
Standardowe parametry, które wymaga procesora w dyrektywie.
- providesArguments
Typ: System.Collections.Generic.IDictionary<String, String>
Standard parametry, które przewiduje dyrektywa procesora.
Uwagi
Ponieważ GenerateTransformCode można dodawać metody do klasy transformacji wygenerowany kod inicjujący często jest niezbędny do wywoływania tych metod.
Ta metoda jest wywoływana raz dla każdej dyrektywy, która przetwarza tego procesora.W związku z tym, można dołączyć kod do każdej dyrektywy codeBuffer.GetPostInitializationCodeForProcessingRunzwraca zawartość codeBuffer po przetworzeniu wszystkich dyrektyw.
Ta metoda jest wywoływana ProcessDirective.
Przykłady
Ten przykład generuje kod po klasy podstawowej jest zainicjowany.W tym przykładzie jest częścią większej przykład RequiresProvidesDirectiveProcessor klasy.
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 + "\");");
}
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Przy użyciu bibliotek z częściowo zaufanego kodu..
Zobacz też
Informacje
RequiresProvidesDirectiveProcessor Klasa