IModel.SetField method
Namespace: NextDesign.Core
Description
Sets the specified field of this instance to the specified value.
An exception is thrown if a value is specified that cannot be set for the specified field.
If the multiplicity of the specified field is 2 or more, set the first element of the corresponding field.
argument
Name | Type | Description |
---|---|---|
fieldName | string | Field name You cannot specify null or an empty string. |
value | object | field value |
Return value
- void
Exceptions
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 this instance's metaclass |
ExtensionInvalidTypeException | If a value that cannot be set in the specified field is specified for value that does not match the type of the field - Null in the field value of a primitive type other than a string type or rich text type. A value is specified - A primitive incompatible type is specified - An enumeration type difference is specified - A primitive type value or an enumeration value is specified in a class type field specified - incompatible class type specified | |
Illegal operation | ExtensionInvalidOperationException | If the model itself is a deleted model or a temporary proxy If an inoperable field is specified in the field name - Product line feature assignment field - System. Fields tagged with Core |
Circular reference | ExtensionCircularReferenceException | When the argument value specifies the invocation target of this method or its ancestors when invoking an owned field of a class type |
ExtensionInvalidModelException with invalid model specified |
Annotations
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 corresponding 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 depend on the field type as follows.
-
Primitive type fields (integer, real, boolean, string, rich text)
Fields of primitive types can have values that can be implicitly cast to the corresponding C# type.
However, for rich text type fields, only the string type can be set. At this time, the decoration as rich text format by tag specification such as<b>
is not interpreted.
Also, for primitive type fields, you can set a string that can be converted to a value of the desired type by the Parse method attached to the corresponding C# type.
Null can be set for string type and rich text type, and the following values can also be set.- object type: value converted to string by ToString method
- object type: value converted to string by ToString method
-
enum field
Enumerated fields can be set to strings corresponding to literals.
Conversion to literals is possible in the following cases:- If there is one with a literal name that matches the string, convert it to that literal.
- If there is no matching literal name, convert to the first literal found if the string has a literal display name match.
- If there is one with a literal name that matches the string, convert it to that literal.
-
Class type field
Class type fields can have IModel type instances and null.
If a value of type IModel is specified, sets 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, moves the model specified in the argument as a child of the method caller's model. It also removes the model that was already set.
- For references, add a reference relationship with the model specified by the argument. Also, delete the existing reference relationship with the model that was already set. The model itself, which has already been set, is not deleted.
If null is specified, it will only unset models that have already been set.
- If owned, delete the already set model.
- In case of reference, delete the existing reference relationship with the model that was already set. The model itself, which has already been set, is not deleted.
If the field multiplicity bound is greater than or equal to 2, the 0th element is dropped and subsequent elements are shifted forward.
- If owned, moves the model specified in the argument as a child of the method caller's model. It also removes the model that was already set.