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
Name | Type | Description |
---|---|---|
fieldName | string | Field name Null or empty string cannot be specified. |
className | string | Class name Specify the name of the class or the fully qualified name. Null or empty string cannot be specified. |
direction | string | Add direction - "first" : Beginning - "last" : End - "before" : Before - "after" : After |
index | int | Add 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. |
fuzzy | bool | Fuzzy 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
Name | Exception class | Description |
---|---|---|
Invalid argument | ExtensionArgumentException | If 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 found | ExtensionFieldNotFoundException | If the specified field is not found in the metaclass of this instance |
Invalid field access | ExtensionIllegalFieldAccessException | If this method is executed for a field whose multiplicity limit is 1 |
Invalid index range | ExtensionOutOfRangeException | If 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 field | ExtensionInvalidTypeException | If 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 found | ExtensionTypeNotFoundException | If the specified class cannot be found |
Invalid operation | ExtensionInvalidOperationException | If 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 |