Skip to main content

IModel.AddNewModelTo 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

NameTypeDescription
fieldNamestringField Name
Cannot be null or an empty string.
It must also be an owned field of the class type.
classNamestringClass 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.
directionstringAddition direction
- "first" : First
- "last" : Last
- "before" : Before
- "after" : After
targetIModelAddition base model
The addition position is determined based on the model position specified here.
If direction is specified as "first", it will be added to the beginning regardless of the base model.
If direction is specified as "last", it will be added to the end regardless of the base model.
If direction is specified as "before", the instance will be added to the position of the specified model, and if it is "after", the instance will be added to the position after the specified model.
fuzzyboolFuzzy match option
Whether to treat the className argument as the name of the class rather than the 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

NameException ClassDescription
Invalid ArgumentExtensionArgumentExceptionWhen null or an empty string is specified for fieldName or className
When a string other than the default string is specified for direction
When the model specified as the basis for the addition position is not included in the field value
Field Not FoundExtensionFieldNotFoundExceptionWhen the specified field is not found in the metaclass of this instance
Invalid Field AccessExtensionIllegalFieldAccessExceptionWhen this method is executed on a field with a multiplicity limit of 1
Invalid Specified FieldExtensionInvalidTypeExceptionWhen 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 specified field type and the specified class are incompatible
Class not foundExtensionTypeNotFoundExceptionIf the specified class is not found
Invalid operationExtensionInvalidOperationExceptionIf the model itself has been deleted or is a temporary proxy
If an unoperable field is specified as the field name
- Product line feature assignment field
- Field with System.Core tag
If an invalid field is specified