5

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.

4

1 回答 1

4

我自己没有尝试过,但是阅读了文档,它似乎可以序列化任何东西,尽管您可能需要编写一个自定义转换器。以下包含子对象的代码作为需要自定义转换器的对象的示例给出。

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;
于 2011-03-29T20:13:09.827 回答