Attribute Definition / Additional Interfaces / Additional Namespaces Macro Definitions

The LLBLGen Pro designer allows you to specify additional interfaces, additional namespaces and attribute definitions for elements, which are generated into the generated code. To add additional interfaces / additional namespaces and/or attribute definitions to an element, you either use the Project Settings Editor or edit the additional interfaces, additional namespaces and attributes on the code generation info tab of the various elements. To make the definition as generic as possible (so the additional interfaces, additional namespaces and attribute definition can be defined at the project level in the Project Properties Editor), macros can be used.

Macros usable only for Attribute Definitions

The following macros are supported only for attribute definitions.

$true
This is resolved to the trueKeyword value in the used language
$false
This is resolved to the falseKeyword value in the used language
$null
This is resolved to the nullKeyword value in the used language
$typeof
This is resolved to the typeofKeyword value in the used language
$=
This is resolved to the attributeAssignmentOperator definition in the used language
$length
This is resolved to the length of the field the attributed is defined on.
$precision
This is resolved to the precision of the field the attributed is defined on
$scale
This is resolved to the scale of the field the attributed is defined on
$byte
This resolves to the byteKeyword which is a cast keyword for casting the value specified after it to byte.
$int16
This resolves to the int16Keyword which is a cast keyword for casting the value specified after it to short.
$int32
This resolves to the int32Keyword which is a cast keyword for casting the value specified after it to int.
$int64
This resolves to the int64Keyword which is a cast keyword for casting the value specified after it to long.
$single
This resolves to the singleKeyword which is a cast keyword for casting the value specified after it to single/float.
$double
This resolves to the doubleKeyword which is a cast keyword for casting the value specified after it to double.
$decimal
This resolves to the decimalKeyword which is a cast keyword for casting the value specified after it to decimal.
{$FriendlyName}
This resolves the element's name into a friendly name, where PasCal cased name fragments are prefixed with a space, and underscores are removed and replaced by a space. Example: OrderNumber and Order_Number will both become Order number. You can use this in e.g. Display() attribute definitions on elements. The element name without a group name or parent container name is used.

Macros usable for Attribute Definitions, Additional Namespaces and Additional Interfaces

The following macros are supported for Attribute Definitions, Additional Namespaces and Additional Interfaces. These have a slightly different syntax as the macros above and are given below.

{$ContainerName}

This resolves to the name of the containing element, if applicable, or an empty string if the element isn't contained inside another element (e.g. entities aren't contained in anything). In case of a Root Derived Element this is the name of the Derived Model. In case of an Embedded Derived Element, it's equal to the name of the embedding field.

{$FullName}

This resolves to the name of the element and the containing element which can be the containing element's name or the group name, in case of an element in the Entity Model. In case of an element in a Derived Model, it resolves to DerivedModelName.RootDerivedElementName in case of a Root Derived Element, and to EmbeddingFieldName.EmbeddedRelatedElementName in case of an Embedded Derived Element.

{$GroupName}

This resolves to the name of the group the element is in, which is the group of the containing element in the case of a field. In case of a derived element it resolves to the empty string.

{$Name}
This resolves to the name of the element

Attributes and constants

.NET Attribute definitions are defined using constants, it therefore might be necessary to specify a specific type for a constant. E.g. 10 is seen as an integer, but it might be necessary to define that as a byte or short/Int16. To do this, one should use the 5 specific cast keywords if the value specified is ambiguous and by default is seen as a value of a different type: numbers without fraction are by default seen as integers by compilers and numbers with fraction are by default seen as doubles.

To specify a cast, use the syntax: $typename(value). For example: $byte(10). This will resolve to either (byte)(10) for C#, or to CByte(10) for VB.NET. Not specifying the value in parenthesis could cause problems for vb.net and there's no checking done on this.

It's not necessary to wrap the attribute in [] characters for C# or <> characters for VB.NET nor is it necessary to append a _ for VB.NET, this is done by the code generator automatically.