IModel.SetField method

Namespace: NextDesign.Core

Description

Sets the designated field in this instance with the given value. If a value that cannot be set for the specified field is specified, an exception will be thrown. 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
Null or empty string cannot be specified.
value object field value

Return value

  • void

Exception

Name Exception Class Description
Invalid argument ExtensionArgumentException When null or empty string is specified in fieldName
Field not found ExtensionFieldNotFoundException If the specified field is not found in this instance's metaclass
Does not match field type ExtensionInvalidTypeException value that does not match the field type
-A null value is specified for the value of the primitive type field other than the string type and rich text type. Are specified
-Primitive incompatible types are specified
-Enumeration type differences are specified
-Class type field has a primitive type value or an enumeration value is specified
-Incompatible class type specified
Illegal operation ExtensionInvalidOperationException If the model itself is a deleted model or temporary proxy
If an inoperable field is specified in the field name
-Product line feature assignment field
-System.Core tag Assigned field
Circular reference ExtensionCircularReferenceException When calling the owned field of the class type and specifying the call target of this method or its ancestor in the argument value
Invalid model specified ExtensionInvalidModelException When deleted model or temporary proxy is specified in the value of field

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. When using this API, it is necessary to change the relevant part in the extension along with the version upgrade to Ver.1.1 or later.

About the values that can be set depending on the field type

The values that can be set depend on the field type as follows.

  • Primitive field (integer, real, boolean, string, rich text)

    Primitive type fields can have values that can be implicitly cast to the corresponding C# type. However, for rich text type fields, only string type can be set. At this time, decoration as rich text format by specifying tags such as <b> is not interpreted. In addition, in the field of the primitive type, you can set the string that can be converted to the value of the target type by the Parse method attached to the corresponding C# type. In case of character string type/rich text type, setting of null is allowed and the following values can be set.

    • object type: Value converted to a string by the ToString method
  • Enumerated fields

    For enumerated fields, you can set a string that corresponds to a literal. Conversion to a literal is possible in the following cases.

    • If there is a literal name that matches the character string, convert it to that literal.
    • If no string has a matching literal name, then if any of the strings match the literal display name, convert it to the first found literal.
  • Class type field

    You can set an instance of IModel type and null in a field of class type.

    If a value of type IModel is specified, 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.
    • In case of reference, add reference association with the model specified by the argument. In addition, the reference relation that existed with the already set model is deleted. The model that has already been set is not deleted.

    If null is specified, only the model that has already been set will be unset.

    • If you own, delete the already set model.
    • In case of reference, delete the reference relation that existed with the already set model. The model that has already been set is not deleted.

    If the multiplicity limit of the field is 2 or more, the 0th element is deleted and the following elements are moved forward.