Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

The OnPostRender event is fired after CodeSmith has Generator has merged metadata with your template to produce the output. You can use this event to perform any additional processing you would like after CodeSmith has Generator has finished its job. For example, the StoredProcedures.cst sample template included with CodeSmith uses Generator uses this event to autoexecute the generated SQL script:

Code Block
xml
languagexmlcsharp

protected override void OnPostRender(string result)
{
    if (this.AutoExecuteScript)
    {
        // execute the output on the same database as the source table.
        CodeSmith.BaseTemplates.ScriptResult scriptResult = CodeSmith.BaseTemplates.ScriptUtility.ExecuteScript(
            this.SourceTable.Database.ConnectionString,
            result,
            new System.Data.SqlClient.SqlInfoMessageEventHandler(cn_InfoMessage)
             );

        Trace.Write(scriptResult.ToString());
    }

     base.OnPostRender(result);
}