Skip to main content

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

NameTypeDescription
fieldNamestringField name
Cannot be null or an empty string.
classNamestringClass name
Specify the name of the class or the fully qualified name.
Cannot be null or an empty string.
fuzzyboolFuzzy 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

NameException classDescription
Invalid argumentExtensionArgumentExceptionIf null or an empty string is specified for fieldName or className
Field not foundExtensionFieldNotFoundExceptionIf the specified field is not found in the metaclass of this instance
Invalid specified fieldExtensionInvalidTypeExceptionIf 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 foundExtensionTypeNotFoundExceptionWhen the specified class cannot be found.
Invalid operationExtensionInvalidOperationExceptionWhen 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.