3

So for example how to serialise an object like this:

unit u_Configuration;

interface

uses
  Classes,
  Generics.Collections,
  OmniXML,
  OmniXMLPersistent
  ;

type
  TMyObject = class (TPersistent)
    strict private
      fName : String;
    public
    published
      property Name: String read fName write fName;
  end;

  TConfiguration = class(TPersistent)
    strict private
      fTheList : TList<TMyObject>;
    private
    public
    published
      property TheList: TList<TMyObject> read fTheList write fTheList;

  end;

implementation

end.
TLama
  • 75,147
  • 17
  • 214
  • 392
sav
  • 2,064
  • 5
  • 25
  • 45

1 Answers1

2

OmniXML serializes descendants of TPersistent. It serializes their properties, but for properties having object types, only descendants of TPersistent are serialized. TList descends from TEnumerable, which descends from TObject, so it doesn't qualify. OmniXML has special handling built in for TCollection.

You can serialize other classes manually.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467