Built In Helpers

This topic details the Artefact Template Helper Types that are built into DesiGen, and available for use in your own artefact templates.

Default and Per-Template Helpers

There are two ways in which helpers are made available. There are some default helpers that are always made available without you needing to ask for them. Other helpers exist, but for these you need to specify that you want them to be available on a per-template basis.

Default Helpers

Default helpers are those ubiquitous helpers that are so useful that we expose them to all templates by default. The following helper types are made available in this way:

StringUtilities

General string manipulation helpers.

NameConverter

This helper offers name conversions for the primary language of the template. It makes use of settings for that language to ensure consistent application of the naming conventions you choose for your code.

MultilingualNameConverter

Built on top of NameConverter, this helper offers name conversion for a named language; this allows use of name conversion for languages other than the primary language defined for the template.

NameTemplater

This helper offers templating of names for the primary language of the template. It makes use of settings for that language to ensure consistent application of the naming conventions you have set up for your code.

Name templating is the bringing together of name conversion and the specification of a custom naming template. For example, if you want interfaces to start with an I, then you can specify this as part of a naming template.

MultilingualNameTemplater

Built on top of NameTemplater, this helper does name templating for a named language; this allows use of name conversion and templating for languages other than the primary language defined for the template.

FieldNameConverter

FieldNameConverter exposes functionality to transform the name of a Field defined as part of a Data Structure into a format that suits the coding standards defined in the settings of a language.

ArtefactNameConverter

ArtefactNameConverter exposes functionality to transform the name of an Artefact into a format that suits the coding standards defined in the settings of a language.

DataTypeConverter

DataTypeConverter exposes functionality to transform the name of a data type defined against a Field as part of a Data Structure into a format that suits the coding standards defined in the settings of a language.

PrimaryKeySnippetGenerator

PrimaryKeySnippetGenerator exposes enhanced functionality to generate code snippets associated with all of the fields that make up the primary key of a Data Structure.

ValidationRuleSnippetGenerator

ValidationRuleSnippetGenerator exposes functionality that allows the generation of validation rules on a property based upon the configuration of a Field in a Data Structure. Multiple validation rules may be considered appropriate in certain circumstances, so this may expose multiple lines in the snippet.

Built-in Per-Template Helpers

The following Helpers exist for your use within your templates, but must be specified as part of the definition of your artefact template in order to be available for your use.

When specifying that you want these types to be available for your use in code generation templates, you must specify the code that represents them in the Helpers property of the ArtefactTemplate definition, plus the code that represents the code generation template source. However, inside of your code generation templates, you need specify only the short name defined in the title of the class to access the methods the type exposes.

For example, if we export the built-in "Empty solution" template, our definition would include the following JSON for the helpers required:

  "Helpers": [
    {
      "CodeGenTemplateSourceCode": "BUILTIN",
      "ArtefactTemplateHelperTypeCode": "BI-GuidUtilities"
    }
  ],

An example of usage of the helper within the template text is as follows:

{{ GuidUtilities.NewGuidInCurlyBraces(NamingContext) }} 

GuidUtilities

"CodeGenTemplateSourceCode": "BUILTIN",
"ArtefactTemplateHelperTypeCode": "BI-GuidUtilities"

This class exposes utility methods associated with the Guid data type, including the ability to generate new, random Guid values.

StoredProcedureNameConverter

"CodeGenTemplateSourceCode": "BUILTIN",
"ArtefactTemplateHelperTypeCode": "BI-SQL-StoredProcedureNameConverter"

A T-SQL specific converter for generating the names of stored procedures for specific data operations.

StoredProcedureSnippetGenerator

"CodeGenTemplateSourceCode": "BUILTIN",
"ArtefactTemplateHelperTypeCode": "BI-SQL-T_SQL-StoredProcedureSnippetGenerator"

A T-SQL specific class for generating snippets of T-SQL stored procedures.

TableSnippetGenerator

"CodeGenTemplateSourceCode": "BUILTIN",
"ArtefactTemplateHelperTypeCode": "BI-SQL-T_SQL-TableSnippetGenerator"

A T-SQL specific class for generating snippets associated with T-SQL tables, especially table creation scripts.

DataReaderSnippetGenerator

"CodeGenTemplateSourceCode": "BUILTIN",
"ArtefactTemplateHelperTypeCode": "BI-CSharp-DataReaderSnippetGenerator"

A C#-specific generator class, which can generate snippets associated with accessing a Field via a .NET DataReader class.

CSLAFieldNameConverter

"CodeGenTemplateSourceCode": "BUILTIN",
"ArtefactTemplateHelperTypeCode": "BI-CSharp-CSLA-CSLAFieldNameConverter"

A C#-specific converter associated with the CSLA framework, which can create appropriate names for
parts of a CSLA business object.

CSLASnippetGenerator

"CodeGenTemplateSourceCode": "BUILTIN",
"ArtefactTemplateHelperTypeCode": "BI-CSharp-CSLA-CSLASnippetGenerator"

A C#-specific generator class associated with the CSLA framework, which can generate snippets for defining parts of a CSLA business object.