DomainModel.CreateElement Method
Visual Studio 2008
Creates an element of a specified type.
Assembly: Microsoft.VisualStudio.Modeling.Sdk (in Microsoft.VisualStudio.Modeling.Sdk.dll)
public virtual ModelElement CreateElement( Partition partition, Type elementType, PropertyAssignment[] propertyAssignments )
Parameters
- partition
- Type: Microsoft.VisualStudio.Modeling.Partition
The partition where element is to be created.
- elementType
- Type: System.Type
A non-abstract domain class defined in the DSL Definition.
- propertyAssignments
- Type: Microsoft.VisualStudio.Modeling.PropertyAssignment[]
Specify values for the domain properties defined for the domain class.
MyDslDomainModel dm = ...;
PropertyAssignment nameProperty =
new PropertyAssignment(ExampleElement.NameDomainPropertyId, "element1");
ExampleElement element = dm.CreateElement(
dm.Store.DefaultPartition,
typeof(ExampleElement),
new PropertyAssignment[] {nameProperty}
) as ExampleElement;
The following example has the same effect:
ExampleElement element1 = new ExampleElement(dm.Store); element1.Name = "element1";
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.