IModel.AddNewModelAt Method
Namespace: NextDesign.Core
Description
Adds an instance of the specified class as a field value to the specified field of this instance, specifying the addition position.
Even if the specified class is an abstract class, the instance will be added as a field value at the specified position.
Argument
| Name | Type | Description |
|---|---|---|
| fieldName | string | Field Name Cannot be null or an empty string. It must also be an owned field of the class type. |
| className | string | Class Name Specify the name or fully qualified name of the class. Cannot be null or an empty string. It must also be of a type compatible with the field's data type. |
| direction | string | Addition direction - "first" : beginning - "last" : end - "before" : before - "after" : after |
| index | int | Addition reference position Specifies an index where the starting position is 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 specified as "before", the instance will be added at the specified position, and if it is "after", the instance will be added at the position after the specified position. |
| fuzzy | bool | Fuzzy matching option Whether to treat the className argument as the name of the class rather than its fully qualified name. If False, it will be evaluated as specifying a class whose fully qualified name matches className. If True, it will be evaluated as specifying a class whose class name matches className. If there are multiple matching classes, it adds the first type-compatible class instance found. The default value is True. |
Return value
Exceptions
| Name | Exception Class | Description |
|---|---|---|
| Invalid Argument | ExtensionArgumentException | When null or an empty string is specified for fieldName or className When a string other than the default string is specified for direction |
| Field Not Found | ExtensionFieldNotFoundException | When the specified field is not found in the metaclass of this instance |
| Illegal Field Access | ExtensionIllegalFieldAccessException | When this method is executed on a field with a multiplicity limit of 1 |
| Invalid Index Range | ExtensionOutOfRangeException | When a negative number is specified for index Or, when a value greater than or equal to the number of elements in the field is specified for index |
| Invalid Specified Field | ExtensionInvalidTypeException | When a value that cannot be set is specified for the specified field - 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 and the specified class are incompatible. |
| Class not found | ExtensionTypeNotFoundException | If the specified class is not found. |
| Invalid operation | ExtensionInvalidOperationException | If the model itself has been deleted or is a temporary proxy. If an unoperable field is specified as the field name. - Feature assignment field in a product line. - Field with the System.Core tag. If an invalid field is specified. |