Skip to main content

IModel.AddNewModelAt Method

Namespace: NextDesign.Core

Description

Adds an instance of the specified class to the specified field of this instance as a field value by specifying the addition position.
Even if the specified class is an abstract class, instantiation is allowed and it is added as a field value at the specified position.
The specified field must be an owned field of the class type.
Note that an exception will not be thrown even if the upper multiplicity constraint of a field with a multiplicity of 2 or more is violated.
The specified class name must be a type compatible with the data type of the field.
In addition, when there are multiple matching classes when performing a fuzzy match, an instance of the first type-compatible class found will be added.

Arguments

NameTypeDescription
fieldNamestringField name
Null or empty string cannot be specified.
classNamestringClass name
Specify the name of the class or the fully qualified name.
Null or empty string cannot be specified.
directionstringAdd direction
- "first" : Beginning
- "last" : End
- "before" : Before
- "after" : After
indexintAdd reference position
Specify an index with the first position being 0.
If "direction" is specified as "first", it will be added to the beginning regardless of the index value.
If "direction" is specified as "last", it will be added to the end regardless of the index value.
If direction is "before", the instance is added to the specified position; if direction is "after", the instance is added to the position following the specified position.
fuzzyboolFuzzy match option
Whether to treat the className argument as the name of a class rather than a fully qualified name.
If False, it is evaluated as specifying a class whose fully qualified name matches className.
If True, it is evaluated as specifying a class whose class name matches className.

The default value is True.

Return value

Exception

NameException classDescription
Invalid argumentExtensionArgumentExceptionIf null or an empty string is specified for fieldName or className
If a string other than the default string is specified for direction
Field not foundExtensionFieldNotFoundExceptionIf the specified field is not found in the metaclass of this instance
Invalid field accessExtensionIllegalFieldAccessExceptionIf this method is executed for a field whose multiplicity limit is 1
Invalid index rangeExtensionOutOfRangeExceptionIf a negative number is specified for index
Or if a value equal to or greater than the number of elements in the corresponding field is specified for index
Invalid specified fieldExtensionInvalidTypeExceptionIf a value that cannot be set for the specified field is specified
- The specified field is not an owned field
- The data type of the specified field is not a class type
- The type of the specified field is not compatible with the specified class
Class not foundExtensionTypeNotFoundExceptionIf the specified class cannot be found
Invalid operationExtensionInvalidOperationExceptionIf the model itself is a deleted model or a temporary proxy
If an inoperable field is specified for the field name
- Feature assignment field of a product line
- Field with the System.Core tag
If an invalid field is specified