The LLBLGen Pro designer generates source-code and the generated classes might be required to inherit from additional .NET interfaces and the code files might need to reference additional namespaces. Modifying generated property definitions in generated classes is risky as they get overwritten the next time the code is overwritten.
For this reason the LLBLGen Pro designer offers a way to define the additional interfaces and namespaces at the model level, so they can be generated into the generated code on classes representing the associated elements.
There are two levels you can define the additional namespaces and interfaces: at the project level and at the element level. Every addtional interface and namespace defined on the project level for a given element type (e.g. 'Entity'), is inherited by an instance of that type: e.g. the entity definition 'Customer' as an entity inherits the additional interfaces and namespaces defined for 'Entity' at the project level'.
At the element level, you can decide whether the particular element
indeed inherits the additional interface or namespace (leave it as-is)
or not (uncheck the Inherit checkbox). If just a few elements
shouldn't get a particular interface or namespace defined at the project
level, this isn't a big problem. However if an additional interface or
namespace should only be assigned to an element with specific aspects
(e.g. the interface
IMyValidation should only be assigned to Entity
Definitions which are a sub-type), it gets time consuming to uncheck all
LLBLGen Pro therefore allows you to define rules for each additional namespace or interface defined on the project level. A rule is an expression which has to resolve to true for the element at hand if the interface or namespace is to be defined on said element. If the rule resolves to true (or there's no rule) the element will inherit the additional interface / namespace.
By default no rule is present for an additional interface or namespace, which means it's defined on all elements of the given type. This means that for the
interface on the element type Entity, we can define a rule which
states that Is sub-type should be true. The rule only resolves to true
for entity definitions which are subtypes, so only these entities will
inherit this interface at the element level.
To edit a rule for an additional interface or namespace, in the tree on the left browse to Project Settings -> Conventions -> Entity Model and click Additional Interfaces, or Additional Namespaces, and select the element type the interface resp. namespace is defined for on the right. For the interface / namespace to edit the rule for, click the button in the Has Rule column. This opens the rule editor which is a dynamic dialog. At first, there's only a [+] button, which allows you to add the first expression. Clicking a [+] adds a new expression part to the full expression, and which are combined using logical operators selectable in the dialog.
Clicking OK saves the rule for the additional namespace or interface in the project settings. When OK is clicked to close the Project Settings Editor, the additional interfaces and namespaces are assigned immediately. This is dynamic, so changing an aspect of an element, e.g. the type of a field, will immediately have the effect that the additional interfaces / namespaces are updated.
To be able to define additional interfaces which reflect values of the element they're defined on (e.g. the name of the element in the name of the additional interface), LLBLGen Pro uses a macro language. It's described in more detail in its own section.