Skip to main content

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

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" : beginning
- "last" : end
- "before" : before
- "after" : after
indexintAddition 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.
fuzzyboolFuzzy 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

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
Field Not FoundExtensionFieldNotFoundExceptionWhen the specified field is not found in the metaclass of this instance
Illegal Field AccessExtensionIllegalFieldAccessExceptionWhen this method is executed on a field with a multiplicity limit of 1
Invalid Index RangeExtensionOutOfRangeExceptionWhen 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 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 type of the specified field 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.
- Feature assignment field in a product line.
- Field with the System.Core tag.
If an invalid field is specified.