Defining Domain Models
Updated: July 2008
The first step in defining a domain-specific language is to add domain classes and domain relationships to the domain model.
Domain Classes and Named Domain Classes
You can add a domain class or named domain class by dragging the one that you want from the Toolbox to the diagram. For more information, see Defining Domain Classes.
You can add a domain property to a domain class by right-clicking the Domain Properties compartment of the domain class on the diagram and then clicking Add New Domain Property. You can change the name and the type of the domain property in the Properties window. You can add your own external types or enumerations to the model. For more information, see Defining Domain Properties.
Domain Enumerations and Enumeration Literals
You can add a domain enumeration by right-clicking the root of the model in the DSL Explorer and then clicking Add New Domain Enumeration. The element will appear in the DSL Explorer under the Domain Types node. This element does not appear on the diagram. To add enumeration literals to the domain enumeration, right-click the domain enumeration in the DSL Explorer and then click Add New Enumeration Literal.
An external type is not defined by the domain-specific language; instead, it is defined by another source, for example, System.Drawing.Color. In the DSL Explorer, right-click the root of the model, and then click Add New External Type. After you add the external type, give it the correct type name in the Properties window. For more information, see Defining Domain Enumerations and External Types.
To add an embedding relationship, in the Toolbox, select the Embedding Relationship tool and, in the diagram, click the first domain class and then click the second domain class. If the relationship is valid, it will appear on the diagram as a line that contains a box for the name of the embedding relationship. The source domain class of an embedding relationship is the domain class that is the parent of the target domain class. By default, the name of the domain relationship is composed of the Name property of the source domain class (the containing class) and the Property Name property of the source domain class, as follows: SourceClassNameHasSourcePropertyName. If you change the name of a role on one end of the relationship, the relationship name will change to SourceRoleHasTargetRole. You can change these names.
You can add a reference relationship between two domain classes by selecting the Reference Relationship tool in the Toolbox, and then clicking the first domain class and then the second domain class. If the relationship is valid, it will appear on the diagram as a dotted line that contains a box for the name of the reference relationship. By default, the name is SourceClassReferencesSourcePropertyName.. If you change the name of a role on one end of the relationship, the relationship name will change to SourceRoleReferencesTargetRole. You can change these names.
You can add an inheritance relationship by selecting the Inheritance tool in the Toolbox, and then dragging the derived class to the base class. If the relationship is valid, it will appear on the diagram as a straight line that has a hollow arrow that points from the derived class to the base class. Inheritance relationships do not have names or other properties.
For more information, see Defining Domain Relationships.
Element Merge Directives
By using element merge directives, you can specify what occurs when an element is added to the model. You can specify that new relationships are to be added between a new element and existing elements, or specify that a new element be made a child of an existing element. For more information, see How to: Add Element Merge Directives.
Domain Type Descriptors
You can use domain type descriptors to add information to the elements of your domain-specific language, in particular by creating a reference between a domain class and a property of a second domain class. For more information, see Defining Domain Type Descriptors.
You can customize how model elements and relationships are deleted. For more information, see How to: Modify Deletion Behavior.
You can add attributes to modify your model elements. For more information, see How to: Add Custom Attributes.
Changing the Namespace
You can change the namespace of your domain-specific language. For more information, see How to: Change the Namespace of a Domain-Specific Language.