共用方式為


RequiresProvidesDirectiveProcessor.GenerateTransformCode 方法

在衍生類別中覆寫時,將程式碼加入至所產生的轉換類別。

命名空間:  Microsoft.VisualStudio.TextTemplating
組件:  Microsoft.VisualStudio.TextTemplating.11.0 (在 Microsoft.VisualStudio.TextTemplating.11.0.dll 中)

語法

'宣告
Protected MustOverride Sub GenerateTransformCode ( _
    directiveName As String, _
    codeBuffer As StringBuilder, _
    languageProvider As CodeDomProvider, _
    requiresArguments As IDictionary(Of String, String), _
    providesArguments As IDictionary(Of String, String) _
)
protected abstract void GenerateTransformCode(
    string directiveName,
    StringBuilder codeBuffer,
    CodeDomProvider languageProvider,
    IDictionary<string, string> requiresArguments,
    IDictionary<string, string> providesArguments
)
protected:
virtual void GenerateTransformCode(
    String^ directiveName, 
    StringBuilder^ codeBuffer, 
    CodeDomProvider^ languageProvider, 
    IDictionary<String^, String^>^ requiresArguments, 
    IDictionary<String^, String^>^ providesArguments
) abstract
abstract GenerateTransformCode : 
        directiveName:string * 
        codeBuffer:StringBuilder * 
        languageProvider:CodeDomProvider * 
        requiresArguments:IDictionary<string, string> * 
        providesArguments:IDictionary<string, string> -> unit 
protected abstract function GenerateTransformCode(
    directiveName : String, 
    codeBuffer : StringBuilder, 
    languageProvider : CodeDomProvider, 
    requiresArguments : IDictionary<String, String>, 
    providesArguments : IDictionary<String, String>
)

參數

  • codeBuffer
    型別:System.Text.StringBuilder
    緩衝區,這個緩衝區會在處理執行期間,串連可將這個指示詞處理器新增到產生之轉換類別的程式碼。

備註

這是由 ProcessDirective 所呼叫。

範例

這個範例會產生指示詞處理器的程式碼。 這個程式碼範例是 RequiresProvidesDirectiveProcessor 類別完整範例的一部分。

protected override void GenerateTransformCode(string directiveName, StringBuilder codeBuffer, System.CodeDom.Compiler.CodeDomProvider languageProvider, IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments)
{
// Write code to create a property backed by a field of type XmlDocument.
// 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"'
string fieldName = providesArguments[DomProvidedParameterName].ToLower(CultureInfo.InvariantCulture) + "Value";
string propertyName = providesArguments[DomProvidedParameterName];
codeBuffer.Append(
"XmlDocument " + fieldName + ";" +
"XmlDocument " + propertyName +
"{ get { return this." + fieldName + "; } }");
}

.NET Framework 安全性

請參閱

參考

RequiresProvidesDirectiveProcessor 類別

Microsoft.VisualStudio.TextTemplating 命名空間

GeneratePreInitializationCode

GeneratePostInitializationCode

ProcessDirective