IModel.SetFieldAt Method
Namespace: NextDesign.Core
Description
Sets the specified value to the specified index position of the specified field in this instance.
An exception is thrown if a value that cannot be set to the specified field is specified.
Note that no exception is thrown if the field's multiplicity limit constraint or path constraint is violated.
Argument
| Name | Type | Description |
|---|---|---|
| fieldName | string | Field name Null or empty string cannot be specified. |
| value | object | Field value |
| index | int | Position Specifies an index with the starting position being 0. |
Return value
- void
Exceptions
| Name | Exception Class | Description |
|---|---|---|
| Invalid Argument | ExtensionArgumentException | When null or an empty string is specified for fieldName |
| Field Not Found | ExtensionFieldNotFoundException | When the specified field is not found in the metaclass of this instance |
| Invalid Field Access | ExtensionIllegalFieldAccessException | When this method is executed on a field with a multiplicity limit of 1 |
| Invalid Index Range | ExtensionOutOfRangeException | When 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 |
| Field Type Incompatible | ExtensionInvalidTypeException | When a value that cannot be set for the specified field is specified for value - A primitive type value or an enumeration value is specified for a class type field - Incompatible class type specified |
| Invalid Operation | ExtensionInvalidOperationException | If 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 the System.Core tag If an invalid field is specified |
| Circular Reference | ExtensionCircularReferenceException | When calling on a field owned by a class type, if the argument value specifies the target of this method's call or its ancestor |
| Invalid Model Specified | ExtensionInvalidModelException | If a deleted model or temporary proxy is specified as the field value |
Annotation
Values that can be set depending on the field type
The values that can be set depending on the field type are determined as follows:
-
Primitive type fields (integer, real, boolean, string, rich text)
This method cannot set these values.
-
Enumeration Fields
This method cannot set these fields.
-
Class Fields
Class fields can be set to instances of the IModel interface or null.
If an IModel value is specified, the specified model will be set in place of the model that was already set.
The behavior differs depending on whether the field is owned or referenced.-
If owned, the model specified in the argument is moved as a child of the model that called the method. The model that was already set is also removed.
-
If referenced, a reference relationship is added between the model specified in the argument and the current model. The reference relationship that existed between the current model and the previously set model is also removed. The previously set model itself is not deleted.
If null is specified, only the previously set model is unset.
-
If owned, the previously set model is removed.
-
If referenced, the reference relationship that existed between the current model and the previously set model is removed. The model itself, which was already set, will not be deleted.
-
When null is specified, the element at the specified position is deleted, and the subsequent elements are shifted forward.