unit MegaDemoCustomClass; interface uses uROTypes; type TCustomClass = class(TROComplexType) private FRandomInt: integer; fRandomDouble: double; FRandomStr: string; FRandomWideStr: widestring; public procedure ReadComplex(ASerializer: TObject); override; procedure WriteComplex(ASerializer: TObject); override; published property RandomInt: integer read FRandomInt write FRandomInt; property RandomDouble: double read FRandomDouble write FRandomDouble; property RandomStr: string read FRandomStr write FRandomStr; property RandomWideStr: Widestring read FRandomWideStr write FRandomWideStr; end; function NewCustomClass: TCustomClass; implementation uses SysUtils, uROSerializer, typInfo; function NewCustomClass: TCustomClass; begin result := TCustomClass.Create; Result.RandomInt := Random(1000); Result.RandomDouble := Random * 1000; Result.RandomStr := IntToStr(Random(1000)) + '(string)'; Result.RandomWideStr := IntToStr(Random(1000)) + '(widestring)'; end; { TCustomClass } procedure TCustomClass.ReadComplex(ASerializer: TObject); begin TROSerializer(ASerializer).ReadInteger('RandomInt',otULong,FRandomInt); TROSerializer(ASerializer).ReadDouble('RandomDouble',ftDouble,FRandomDouble); TROSerializer(ASerializer).ReadUTF8String('RandomStr',FRandomStr); TROSerializer(ASerializer).ReadWideString('RandomWideStr',FRandomWideStr); end; procedure TCustomClass.WriteComplex(ASerializer: TObject); begin TROSerializer(ASerializer).WriteInteger('RandomInt',otULong,FRandomInt); TROSerializer(ASerializer).WriteDouble('RandomDouble',ftDouble,FRandomDouble); TROSerializer(ASerializer).WriteUTF8String('RandomStr',FRandomStr); TROSerializer(ASerializer).WriteWideString('RandomWideStr',FRandomWideStr); end; initialization RegisterROClass(TCustomClass); Randomize; end.