例如,如何序列化一个对象,如下所示:
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.发布于 2013-02-26 03:05:48
OmniXML序列化TPersistent的后代。它序列化它们的属性,但是对于具有对象类型的属性,只有TPersistent的后代被序列化。TList是TEnumerable的后代,而from是TObject的后代,所以它不符合条件。OmniXML为TCollection内置了特殊的处理。
您可以手动序列化其他类。
https://stackoverflow.com/questions/15058334
复制相似问题