-
On the Project menu, click GenFromModel Properties.
-
In Default namespace, type ExampleNamespace.
-
Save and close the project properties.
-
In Solution Explorer, expand Properties, and double-click AssemblyInfo.cs to open it.
-
At the bottom of this file, insert the following assembly instruction:
[assembly: System.CLSCompliant(true)]
-
In Solution Explorer, click GenFromModel to highlight it.
-
Add a text file, DomainModel.tt, to the project, and insert the following text into it:
<#@ include file="Dsl\DomainModelCodeGenerator.tt" #>
<#@ Dsl processor="DslDirectiveProcessor" requires="fileName='library.dsl'" #>
Note |
|---|
| When you generate a template, a dialog box opens and warns you not to run text templates from untrusted sources. If you do not want to see this message again, select the Do not show this message again check box, and click OK. Otherwise, click OK. |
-
Add a text file, DomainClasses.tt, to the project, and insert the following text into it:
<#@ include file="Dsl\DomainClassCodeGenerator.tt" #>
<#@ Dsl processor="DslDirectiveProcessor" requires="fileName='library.dsl'" #>
-
Add a text file, DomainRelationships.tt, to the project, and insert the following text into it:
<#@ include file="Dsl\DomainRelationshipCodeGenerator.tt" #>
<#@ Dsl processor="DslDirectiveProcessor" requires="fileName='library.dsl'" #>
-
Add a text file, Diagram.tt, to the project, and insert the following text into it:
<#@ Dsl processor="DslDirectiveProcessor" requires="fileName='library.dsl'" #>
<#@ include file="Dsl\Diagram.tt" #>
-
Add a text file, ToolboxHelper.tt, to the project, and insert the following text into it:
<#@ Dsl processor="DslDirectiveProcessor" requires="fileName='library.dsl'" #>
<#@ include file="Dsl\ToolboxHelper.tt" #>
-
Add a code file, StubMethods.cs, to the project, and insert the following text into it:
using DslModeling = global::Microsoft.VisualStudio.Modeling;
namespace ExampleNamespace
{
public partial class CirculationBook : CirculationBookBase
{
#region Constructors
/// <summary>
/// Constructor
/// </summary>
/// <param name="store">Store where new element is to be created.</param>
/// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
public CirculationBook(DslModeling::Store store, params DslModeling::PropertyAssignment[] propertyAssignments)
: this(store != null ? store.DefaultPartition : null, propertyAssignments)
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="partition">Partition where new element is to be created.</param>
/// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
public CirculationBook(DslModeling::Partition partition, params DslModeling::PropertyAssignment[] propertyAssignments)
: base(partition, propertyAssignments)
{
}
#endregion
}
public partial class LibraryHasMembers : DslModeling::ElementLink
{
internal float GetAmountOwedValue()
{
throw new System.Exception("The method or operation is not implemented.");
}
}
public partial class PersonChecksOutCirculationBooks : DslModeling::ElementLink
{
internal void SetDueDateValue(System.DateTime newValue)
{
throw new System.Exception("The method or operation is not implemented.");
}
internal System.DateTime GetDueDateValue()
{
throw new System.Exception("The method or operation is not implemented.");
}
}
} -
On the File menu, click Save All.
The text templates generate .cs files for the generated API.
-
In Class View, expand the ExampleNamespace node.
The classes that were generated appear.
-
In Solution Explorer, expand the DomainModel.tt node.
The .cs file that was generated appears.
-
Right-click DomainModel.cs, and click View Class Diagram.
The file ClassDiagram1.cd is generated. This file contains the diagram that you created.