| Build a Domain Specific Language with DSL Tools - Map the Notation to the Domain Model (Page 5 of 6 )
The second function of the dsldd file is to map the designer notation onto the domain. In general, this involves mapping shapes to classes and connector lines to relationships, so that as a user creates shapes and connectors in the designer, they are also creating the corresponding classes and relationships in the domain. Again, let’s look at the “BizEntity” example. Navigate to the <shapeMaps> tag in the XML editor, line 74, about one-third of the way through the file.

Notice the <class> element defined as a child the <shapeMap> element. This specifies the class in the domain model which the shape maps to. In this case it is the “Entity” class.
Skip the <compartmentMaps> and <iconMaps> sections for the moment.
Notice the <melCollectionExpression> element defined beneath the <iconMaps> element. This specifies a role in the domain model that an entity must play in order to have a shape created for it. Another way to think of this is that it is specifying the location in the domain model we can find the “Entity” classes we want to map to. In our case, we specify the “ER/Entities” role, which indicates that we want to create an “EntityShape” for all “Entity” instances in the model which are connected to the root element of our domain, which is named “ER”.
Notice the <shape> element defined beneath the <class> element. This specifies the shape in this mapping, in this case the “EntityShape”.
Finally, the <textMaps>, <comparmentMaps>, and <iconMaps> sections map parts of the domain model to text, compartments, and icons which appear on a shape. Notice the use of <expression> elements within these sections to define the mappings.
Next: Generate the Code for the Designer and Build the solution >>
More BrainDump Articles More By MSDN Virtual Labs |