Attribute Definition Macro Definitions
The LLBLGen Pro designer allows you to specify attribute definitions for
elements, which are used to produce .NET attribute definitions in the
generated sourcecode. To add attribute definitions to an element, you either
use the Project Settings Editor
or edit the attributes on the code generation info tab of the element: (Entity,
Typed List,
Typed View or
Value Type). To make
the definition as generic as possible (so the attribute definition can be
defined at the project level in the Project Properties Editor), macros can
be used. The following macros are supported 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.
The macros used in other areas like with additional interfaces, are
supported as well. These have a slightly different syntax and are given
below.
- {$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
- {$Name}. This resolves to the name of the element
- {$FullName}. This resolves to the name of the element and the
containing element which can be the containing entity's name or the
group name
- {$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).
.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 ambiguistic 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.