IModel.AddNewModelTo 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 |
target | IModel | Add reference model The adding 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 reference model. If "direction" is specified as "last", it will be added to the end regardless of the reference model. If direction is "before" the instance is added at the specified model position; if direction is "after" the instance is added at the next position in the specified model. |
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 If the model specified as the criteria for the addition position is not included in the field value |
Field not found | ExtensionFieldNotFoundException | If the specified field is not found in the metaclass of this instance |
Illegal field access | ExtensionIllegalFieldAccessException | If this method is executed for a field with a multiplicity upper limit of 1 |
Specified field invalid | ExtensionInvalidTypeException | If 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 is not compatible with the specified class. |
Class not found | ExtensionTypeNotFoundException | When the specified class cannot be found. |
Invalid operation | ExtensionInvalidOperationException | When the model itself is a deleted model or a temporary proxy. When an inoperable field is specified for the field name. - Feature assignment field of a product line - Field with the System.Core tag When an invalid field is specified. |