CodeGenerator interface

The primary interface for code generation using a template. An instance can be obtained by importing the exported "Generator" constant into the template.

Attributes

NameTypeDescription
templateArgsobject Gets any template arguments that were configured for the template instance in the codegenconfig.json file.  

Operations

NameReturnsDescription
generate(options, template)

CodeGenerator.generate

X

Executes the specified code generation template without any model.

Parameters
NameTypeDescription
optionsCodeGenerationOptions The code generation options.
template(writer: TextWriter) => void A callback function that writes code to the provided TextWriter.
Return value
void
void Executes the specified code generation template without any model. 
generateAsync(options, template)

CodeGenerator.generateAsync

X

Executes the specified code generation template without any model.

Parameters
NameTypeDescription
optionsCodeGenerationOptions The code generation options.
template(writer: TextWriter) => Promise A callback function that writes code to the provided TextWriter. This callback should return a Promise when writing has finished.
Return value
void
void Executes the specified code generation template without any model.  
generateFromModel(options, template)

CodeGenerator.generateFromModel

X

Executes the specified code generation template with the model that is configured for the current template.

Parameters
NameTypeDescription
optionsModelBasedCodeGenerationOptions The code generation options.
template(writer: TextWriter, model: TTargetModel) => void 
Return value
void
void Executes the specified code generation template with the model that is configured for the current template. 
generateFromModelAsync(options, template)

CodeGenerator.generateFromModelAsync

X

Executes the specified code generation template with the model that is configured for the current template.

Parameters
NameTypeDescription
optionsModelBasedCodeGenerationOptions The code generation options.
template(writer: TextWriter, model: TTargetModel) => Promise A callback function that writes code to the provided TextWriter. This callback should return a Promise when writing has finished.
Return value
void
void Executes the specified code generation template with the model that is configured for the current template. 
getModel(options)

CodeGenerator.getModel

X

Gets the model that is configured for the current template.

Parameters
NameTypeDescription
optionsCodeModelOptions [0..1]The model options.
Return value
Type: Promise 
Promise Gets the model that is configured for the current template.