IModel.AddNewModel Method
Namespace: NextDesign.Core
Description
Adds an instance of the specified class to the specified field of this instance as a field value.
The instance is added as the last element of the field.
Even if the specified class is an abstract class, instantiation is allowed and it is added as the last element of the field.
The specified field must be an owned field of the class type.
No exception is thrown even if the upper multiplicity constraint of a field with multiplicity of 2 or more is violated.
The specified class name must be a type compatible with the data type of the field.
Note that when there are multiple matching classes when performing a fuzzy match, an instance of the first type-compatible class found is added.
Arguments
Name | Type | Description |
---|---|---|
fieldName | string | Field name Cannot be null or an empty string. |
className | string | Class name Specify the name of the class or the fully qualified name. Cannot be null or an empty string. |
fuzzy | bool | Fuzzy match option Whether to treat the className argument as the name of a class instead of 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 |
Field not found | ExtensionFieldNotFoundException | If the specified field is not found in the metaclass of this instance |
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 | 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. |