IModel.SetField method
Namespace: NextDesign.Core
Description
Sets the specified field for this instance to the specified value. If a value that cannot be set in the specified field is specified, an exception will be thrown. If the specified field has a multiplicity of 2 or more, the first element of the corresponding field is set.
argument
Name | Type | Description |
---|---|---|
fieldName | string | Field name Null or an empty string cannot be specified. |
value | object | field value |
Return value
- void
Exception
Name | Exception Class | Description |
---|---|---|
Invalid argument | ExtensionArgumentException | When 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 |
If a value that cannot be set in the specified field is specified for | ExtensionInvalidTypeException | value that does not match the field type -null for the value of a primitive type field other than string type and rich text type Value specified -Primitive incompatible type specified -Enumeration type difference specified -Primitive type value or enumeration value specified in class type field Was specified -an incompatible class type was specified |
Illegal operation | ExtensionInvalidOperationException | If it is a deleted model or temporary proxy If an inoperable field is specified in the field name -Product line feature assignment field -System. Fields with Core tags |
Circular reference | ExtensionCircularReferenceException | When calling for a class-type owned field, if the argument value specifies the callee of this method or its ancestors |
Invalid model specified | ExtensionInvalidModelException | When the deleted model or temporary proxy is specified in the field value |
Annotation
About API specification change and migration method in Ver.1.1
From Ver1.1, this method can set null for string type and rich text type fields. If you are using this API, you need to change the relevant part in the extension along with the version upgrade to Ver.1.1 or later.
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 field (integer, real, boolean, string, rich text)
Primitive type fields allow you to set a value that can be implicitly cast to the corresponding C# type. However, for rich text fields, you can only set the string type. At this time, decoration as rich text format by specifying tags such as
<b>
is not interpreted. Also, in a field of primitive type, you can set a string that can be converted to the value of the desired type by the Parse method attached to the corresponding C# type. For character string type and rich text type, null setting is allowed, and the following values can also be set.- object type: Value converted to a string by the ToString method
Enumerated fields
Enumerated fields allow you to set the string that corresponds to the literal. Conversion to literals is possible in the following cases.
- If there is a literal name that matches the string, convert it to that literal.
- If no literal name matches, then if the string matches the literal's display name, convert it to the first literal found.
Class type field
Class type fields can be set to an instance of type IModel and null.
If a value of type IModel is specified, it will set the specified model instead of the model that was already set. At this time, the behavior differs depending on whether the field is owned or referenced.
If owned, move the model specified by the argument as a child of the model that called the method. It also deletes the model that has already been set.
For references, add a reference association with the model specified by the argument. It also removes the reference association that existed with the model that was already set. The model itself that has already been set will not be deleted.
If null is specified, only the model that has already been set will be unset.
If owned, the model that has already been set will be deleted.
For references, delete the reference association that existed with the model that was already set. The model itself that has already been set will not be deleted.
If the field has a multiplicity limit of 2 or greater, the 0th element is removed and subsequent elements are padded.