5
votes

A new article about DataSnap in Delphi XE explains that DataSnap now is able to transfer TObject-descendants between server and client, similar to the Java Enterprise Edition concept of POJO's ("Plain old Java objects").

Does this new feature work if such a PODO has a nested object-type properties which needs to be initialized, for example a TStrings property? Will all of these sub-objects be serialized and transferred with their current values? What about system resource properties, like TFileStream, THandle or TThread, which would make no sense in a serialized object, can these be tagged as 'not serializable'?


Some information is in the DocWiki, including this:

These are the fields for which there is already a built-in conversion/reversion: integer, string, char, enumeration, float, object, record. For the following types, the field values are ignored and user conversion is expected: set, method, variant, interface, pointer, dynArray, classRef, array.

1
Where's David when you need him... <vbg>Lieven Keersmaekers
@Lieven he's concentrating on topics on which he knows more than absolutely nothing!David Heffernan
It does highlight an issue with the StackOverflow system though. When all Delphi questions are snapped up by David and Andreas others just don't get into the habit of coming here to answer questions. I only stop by once every couple of days for exactly that reason, I'm just not needed. We get a question that's outside David and Andreas expertise however and it goes largely unanswered due to the lack of regular Delphi question answerers.LachlanG

1 Answers

4
votes

I haven't tried myself but reading the documentation it appears it will serialize just about anything although you may need to write a custom convertor. The following code which contains sub-objects is given as an example of an object requiring a custom convertor.

type
  TAddress = record
    FStreet: String;
    FCity: String;
    FCode: String;
    FCountry: String;
    FDescription: TStringList;
  end;

  TPerson = class
  private
    FName: string;
    FHeight: integer;
    FAddress: TAddress;
    FSex: char;
    FRetired: boolean;
    FChildren: array of TPerson;
    FNumbers: set of 1..10;
  public
    constructor Create;
    destructor Destroy; override;

    procedure AddChild(kid: TPerson);
  end;