Starting from this section, we will start our DSL journey. First, make sure that you have installed the Visual Studio SDK and use Visual Studio 2008. we will first create a simple DSL project to understand the DSL development environment and process.
1. open. net, new -- Project, click another project type -- extensibility ). the following lists the projects of the vs.net extension type, including projects such as addin, vspackage, and DSL. Select"Domain Specific Lan guage designer ",Click OK
2. next, go to the DSL creation wizard and provide four DSL model templates for us to choose from. In fact, they only provide us with different samples for viewing, which makes it easier for us to start.
Class DiagramsComposed of UML class diagrams, including classes, interfaces, relationships, combinations, attributes, and operations.
Component modelsComponent Model, a component composed of sub-components.
Minimal LanguageOnly contains a simple empty Language Model
Task flowCreate a UML-like state chart model
3. Here we chooseMinimal LanguageAnd keep the default language name. Click Next to design the suffix name and file icon of the language model file. If the entered suffix name has been used, the list of registered suffix names will be listed in the middle box. Here, we enter sm as the suffix and keep the default icon.
4. click "Next" to go to product settings. The main design product name, company, and project namespace are displayed. this information will be included in the last generated project and play a role in the final product deployment. We will not change it here. You can keep the default value directly.
5. in the next step, enter the signature settings. In the extended development process, a strong name is required for any package to be deployed (the package will be registered to GAC). You can select to automatically create a key, you can also select to use an existing key.
6. Create a strong-name key directly and click Next. This is a summary page of settings:
We can directly view all the settings. You can change the settings in the previous step, or click the left-side navigation bar to locate the changes. After confirming the changes are correct, click Finish. The wizard automatically creates a project for us. regardless of the generated project structure, switch to Solution Explorer and click transalte all template ). click debug to run the Visual Studio lab environment (experimental hive ).Minimal LanguageInterface, you can perform some operations. It's amazing. This completes the development of the first DSL project. You can also select the other three models, and the effects are listed above.
7. Let's take a look at the generated project structure. The entire solution consists of two or less projects (the other three, and the testing project after running, which will be introduced later ).
DSL: Model Operations Based on your model data (dsldefinition. dsl file), including model relationships, serialization, graphics, connectors, etc.
Dslpackage: supports operations that DSL can run in vs.net and interact with vs.net, including menus, toolbar, and browser.
The DSL project is set as a friend for the dslpackage project.ProgramSet (through internalsvisibleto of assemblyinfo), dslpackage can directly access internal members in DSL. dslpackage is also based on dsldefinition. DSL generated. it is necessary to gain an in-depth understanding of the structure of the two projects. We will introduce them later.
8. looking at the two projects, we found that most of them are composed of files with the suffix TT. This is the T4 file (Text templating transformation Toolkit), similar to an explanatory language such as ASP and Ruby, read our model to generate CSCode, You can see that each TT file is attached with a CS code file. Bound to each T4 file, you can right-click to run the custom tool run custom tool and then callTexttemplatingfilegeneratorParse the T4 template file to generate the target code. You can also click the button above to convert all template files.
9. open dsldefinition In the DSL project. DSL file. (This is usually the most important file we use, including all the Model Element Data of our DSL, which is affiliated with dsldefinition. DSL. digoal is its graphical display file ).
This is the main area of the model design. Let's take a look at its components:
1) tool bar, which includes the model, relationship, and graphics. The tool bar is related to the. dsl file.
2). model metadata. We will introduce these concepts in the next section.
3). Graphic presentation. display information of the design model. Match the model with the line in the middle.
4). The DSL details editing window is used to edit DSL-related information, such as links.
5). Solution folder. Note that the yellow area above is the "convert all templates" button. Click the DSL explorer tab below to switch to the DSL browser.
The model, model element, graph shape, type, connector ctor, and connection builders in the current DSL file are listed here to read the settings of the Model Browser, tool bar, and serialization. Most of our DSL designs will be completed here.
OK. Here we will introduce some basic concepts next time.
Author: lone knight (like a year of water)
Source: http://lonely7345.cnblogs.com/
The copyright of this article is shared by the author and the blog. You are welcome to repost this article, but you must keep this statement without the author's consent andArticleThe original text connection is clearly displayed on the page. Otherwise, the legal liability is retained.