IModel.SetFieldAt method
Namespace: NextDesign.Core
Description
Sets the specified value at the specified index position of the specified field of this instance.
If a value that cannot be set in the specified field is specified, an exception is thrown.
Note that an exception is not thrown even if the field's multiplicity upper limit constraint or path constraint is violated.
Arguments
Name | Type | Description |
---|---|---|
fieldName | string | Field name Null or an empty string cannot be specified. |
value | object | Value of the field |
index | int | Position Specify an index with the first position being 0. |
Return value
- void
Exception
Name | Exception class | Description |
---|---|---|
Invalid argument | ExtensionArgumentException | If null or an empty string is specified for fieldName |
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 whose upper limit of multiplicity is 1 |
Invalid index range | ExtensionOutOfRangeException | If a negative number is specified for index Or if a value equal to or greater than the number of elements in the corresponding field is specified for index |
Does not match field type | ExtensionInvalidTypeException | If 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 - An incompatible class type is specified. |
Invalid operation | ExtensionInvalidOperationException | If the model itself is a deleted model or a temporary proxy If an inoperable field is specified for 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 an owned field of a class type, if the target of this method or its ancestor is specified in the value argument. |
An invalid model is specified. | ExtensionInvalidModelException | If a deleted model or temporary proxy is specified for the field value. |
Annotation
About values that can be set depending on the field type
The values that can be set are determined by the field type as follows.
- Primitive type field (integers, real numbers, booleans, strings, rich text)
Cannot be set using this method.
- Enumeration field
Cannot be set using this method.
- Class type field
An instance of the IModel interface or null can be set in a class type field.
If an IModel type value is specified, the specified model will be set instead of the model that was already set.
In this case, the behavior differs depending on whether the field is owned or referenced.
-
If owned, the model specified in the argument will be moved as a child of the model that called the method. Also, the already set model will be deleted.
-
If referenced, a reference relationship will be added with the model specified in the argument. Also, the reference relationship that existed with the already set model will be deleted. The already set model itself will not be deleted.
If null is specified, only the setting of the already set model will be canceled.
-
If owned, the already set model will be deleted.
-
If referenced, the reference relationship that existed with the already set model will be deleted. The model itself that has already been set will not be deleted.
When null is specified, the specified element will be deleted and the subsequent elements will be moved forward.