IModel.AddNewModelAt method

Namespace: NextDesign.Core

Description

Adds an instance of the specified class with the specified position to the specified field of this instance as the field value. Allows instantiation even if the specified class is an abstract class and adds it as a field value at the specified position. The specified field must be owned by the class type. Note that no exception is thrown even if the multiplicity upper limit constraint for fields with multiplicity of 2 or more is violated.

The specified class name must be compatible with the field data type. Also, when there is more than one matching class when making a fuzzy match, the instance of the first type-compatible class found is added.

argument

Name Type Description
fieldName string Field name
Null or empty string cannot be specified.
className string Class Name
Specify the class name or fully qualified name.
Null or empty string cannot be specified.
direction string Additional direction
-"first": First
-"last": Last
-"before": Before
-"after": After
index int Additional reference position
Specify the index with 0 as the start position.
When the direction is specified as "first", it will be added to the beginning regardless of the index value.
When the direction is specified as "last", it is added to the end regardless of the index value.
When the direction is "before", the instance is added at the specified position, and when "after", the instance is added at the position next to the specified position.
fuzzy bool className argument as the name of the class instead of the fully qualified name.
If False, evaluates as the class whose fully qualified name matches className.
If True, evaluate as if the class whose class name matches className is specified.

The default value is True.

Return value

Exception

Name Exception Class Description
Incorrect argument ExtensionArgumentException When null or empty string is specified for fieldName or className
direction is specified as a string other than the default string
Field not found ExtensionFieldNotFoundException If the specified field is not found in this instance's metaclass
Illegal field access ExtensionIllegalFieldAccessException When this method is executed for a field whose upper limit of multiplicity is 1
Invalid index range ExtensionOutOfRangeException If a negative number is specified for index
, or if a value greater than the number of elements in the corresponding field is specified for index
Specified field is invalid ExtensionInvalidTypeException If a value that cannot be set is specified for the specified field
-The specified field is not a owned field
-The data type of the specified field is not a class type
-The specified field type is incompatible with the specified class
Class not found ExtensionTypeNotFoundException If the specified class is not found
Illegal operation ExtensionInvalidOperationException If the model itself is a deleted model or temporary proxy
If an inoperable field is specified in the field name
-Product line feature assignment field
-System.Core tag Assigned field