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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With