Share via


Providing Custom Constructors

You can set the HasCustomConstructor property on a ___domain class to true to indicate that you are providing one or more custom constructors.

Custom Constructors Example

The following example uses the sample model Library.dsl, to define a custom constructor for a ___domain class called CirculationBook. To add custom constructors, you create a partial class, define one or more constructors in it, and then add the partial class to the project.

The CirculationBook ___domain class has the GeneratesDoubleDerived property set to true. Therefore, you must define custom constructors for both the CirculationBook class and the CirculationBookBase abstract base class.

using Microsoft.VisualStudio.Modeling;

namespace ExampleNamespace
{
    public partial class CirculationBookBase
    {
        public CirculationBookBase(Partition partition, PropertyAssignment[] propertyAssignments) : base(partition, propertyAssignments)
        {
        }
    }
    public partial class CirculationBook
    {
        public CirculationBook(Partition partition, PropertyAssignment[] propertyAssignments) : base(partition, propertyAssignments)
        {
        }
    }
}

See Also

Concepts

Library.Dsl Overview

Reference

Partition

PropertyAssignment

Other Resources

Domain-Specific Language Tools Glossary