Model-code synchronization provides a powerful method for visualizing your code and providing a strong link between your source files and model objects. PowerDesigner genlets enable you to additionally automate post-generation transformations and handle complex merging of changes to your files.
Genlets are small .NET classes that can be automatically invoked by the synchronization process to perform transformations on the generated files.
There are two kinds of genlets:
Transformlets – perform a transformation on a generated file. They allow you to define reusable cross-target policies to be applied to generated code. For example, you could use transformlets to add a standard header and footer to every file or to ensure that every static field name begins with an underscore
You can chain multiple transformlets together to perform various steps in a transformation.
Mergelets – are of use whenever a given file is being regenerated and the target content may change independently of the model. This may be the case with an XML document in which some sections are generated from a model and others are modified by another system or where standard code skeletons are generated and custom code is added inside the code editor.
In the case of source code, mergelets can be used to maximize readability by preserving order and formatting over multiple generation cycles, by comparing and merging elements at the code model level addresses this issue.
Although especially useful for languages that do not offer partial class support (facilitating the separation of generated and user code), code model mergelets may nonetheless be of use with the VB and C# programming languages. Only one mergelet may be used for each generation.
PowerDesigner provides C# templates for three forms of transformlets and mergelets: