Summary

ElemDefClassAttribute can be applied to array type or field/property of array type to specify the default class of array elements.

Syntax

ElemDefClassAttribute = class(TClassBaseAttr);

Remarks

Due to inheritance the run-time class of array element value can be different from array element compile-time type; value class can be, actually, a sub-class of array element compile-time type. In this case serializer have to write object class name to be able to create an object of correct class during de-serialization. From the other side, serializer will not write object class name, if the object class is equal to element compile-time type; this makes output more readable.

However, if usual value class is different from element compile-time type, ElemDefClassAttribute can be used to change the default class, used by serializer for comparison.

Examples

DelphiCopyCode imageCopy Code
type
  TSubObject = class
  end;

  TObjectArray = array of TObject;

  TMyObject = class
    [ElemDefClass(TSubObject)]
    property SubObjs: TObjectArray;
  end;