Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case FieldCategory.complex: {
const constuctor = getOrCreateConstructor(field.fieldType, typeDictionary) || BaseUAObject;
if (field.isArray) {
(thisAny)[name] = (options[name] || []).map((x: any) =>
constuctor ? new constuctor(x) : null
);
} else {
(thisAny)[name] = constuctor ? new constuctor(options[name]) : null;
}
// xx processStructuredType(fieldSchema);
break;
}
case FieldCategory.enumeration:
case FieldCategory.basic:
if (field.isArray) {
(thisAny)[name] = initialize_field_array(field, options[name]);
} else {
(thisAny)[name] = initialize_field(field, options[name]);
}
break;
}
}
/**
*/
this.setArrayType(initialize_field(schema.fields[1], options.arrayType));
/**
* @property value
* @default null
*/
this.value = initialize_field(schema.fields[2], options.value);
/**
* the matrix dimensions
* @property dimensions
* @type {UInt32[]}
* @default null
*/
this.dimensions = initialize_field_array(
schema.fields[3],
options.dimensions
);
if (options.dataType === DataType.ExtensionObject) {
if (this.arrayType === VariantArrayType.Scalar) {
/* istanbul ignore next */
if (this.value && !(this.value instanceof ExtensionObject)) {
throw new Error("A variant with DataType.ExtensionObject must have a ExtensionObject value");
}
} else {
for (const e of this.value) {
/* istanbul ignore next */
if (e && !(e instanceof ExtensionObject)) {
throw new Error("A variant with DataType.ExtensionObject must have a ExtensionObject value");
}
case FieldCategory.complex: {
const constuctor = getOrCreateConstructor(field.fieldType, typeDictionary) || BaseUAObject;
if (field.isArray) {
(this as any)[name] = (options[name] || []).map((x: any) =>
constuctor ? new constuctor(x) : null
);
} else {
(this as any)[name] = constuctor ? new constuctor(options[name]) : null;
}
// xx processStructuredType(fieldSchema);
break;
}
case FieldCategory.enumeration:
case FieldCategory.basic:
if (field.isArray) {
(this as any)[name] = initialize_field_array(field, options[name]);
} else {
(this as any)[name] = initialize_field(field, options[name]);
}
break;
}
}
if (!uniqueFieldHasBeenFound) {
if (Object.keys(options).length === 0) {
(this as any)[switchFieldName] = 0xFFFFFFFF;
return;
}
const r = schema.fields.filter((f) => f.switchValue !== undefined).map((f) => f.name).join(" , ");
// it is possible also that the switchfield value do not correspond to a valid field
const foundFieldForSwitchValue = schema.fields.findIndex((f) =>
f.switchValue !== undefined && f.switchValue === options[switchFieldName]);