Build a Domain Specific Language with DSL Tools concluded - Introduce notation for the new property
(Page 3 of 6 )
Now we need to modify the notation file so that the new property shows up on the diagram. Double-click on the BizEntity.dsldd file in the Solution Explorer to bring the XML file to the front. Scroll down in the file to find the definition of the connector called “AssociationLink” (line 152).
Note that you may want to close the Visual Studio Toolbox at this point to give the XML editor more room. You can do this by clicking the “X” in the upper right corner of the Toolbox window, located on the left side of the screen.
In this section you will see that within the <decorators> section there are two <connectorText> elements defined. Each of these represents a textual decorator on the connector that is mapped to the Association relationship. You will introduce a new one of these for the new property.
Using copy and paste, duplicate the second <connectorText> element. In the new element, change the name from SourceLabel to TypeLabel and from SourceBottom to TargetTop. Leave the defaultTextId as it is.
<decorators>
<connectorText name="TargetLabel" position="TargetBottom"
defaultTextId="DefaultLabelText"/>
<connectorText name="SourceLabel" position="SourceBottom"
defaultTextId="DefaultLabelText"/>
<connectorText name="TypeLabel" position="TargetTop"
defaultTextId="DefaultLabelText"/>
</decorators>
The previous step defined a textual decorator in the notation, connected to the target end of the AssociationLink connector, and positioned at the top. Now we must define a mapping from this decorator to our new property. Scroll up the file until you find the connectorMap for the AssociationLink connector (line 18).
This has several parts: a <class>, a <connector>, a <sourceMap>, a
<targetMap>, and some <textMaps>.
Using copy and paste, duplicate the complete second <textMap> element (8 lines). In the new element, change TargetLabel to TypeLabel, and
TargetMultiplicity to RelationshipType. Leave everything else as it is. The
changes you should make are indicated in bold red in the XML fragment below. By doing this, you have associated the new decorator with the new property.
<connectorTextMap>
<textDecorator>…
Diagram/Connectors/AssociationLink/ Decorators/ TypeLabel
</textDecorator>
<valueExpression>
<valuePropertyExpression>
<valueProperty>…BizEntity/Association/RelationshipType
</valueProperty>
</valuePropertyExpression>
</valueExpression>
</connectorTextMap>
Save the BizEntity.dsldd file.
Because you have changed the domain model and notation, you must regenerate the code to build the designer. Just as you did earlier, find the Transform All Templates button in the Solution Explorer toolbar, and click it. As before, this command may take a little time to complete. If you get any errors at this point, it may mean that you made a mistake with the instructions for modifying the notation file.

Now build the updated solution, by selecting the
Build Solution option from the Build menu.

Next: Build a Business Entity Model with your new Designer >>
More BrainDump Articles
More By MSDN Virtual Labs