Defines a class which accepts a writer and uses it to write heterogeneous collections (collections that contain items of different item classes.
Note
|
This class can only read and write heterogeneous collections at the TOP level. If a heterogeneous collection contains a heterogeneous collection property, you need to DefineProperty again.
|
Namespace: GStreams
TObject
GStreams.TGSpecialFiler
|
Delphi
|
type
TGSpecialFiler = class
end;
|
|
Name
|
Description
|
|
Create
|
Overloaded. Constructs the special Filer object
|
|
Create(TReader)
|
Overloaded. Constructs the special filer object and prepares it for reading.
|
|
Create(TWriter)
|
Overloaded. Constructs the special filer object and prepares it for writing.
|
Top
|
All collection item classes must be defined with RegisterClass.
|
To use:
For the class that has the heterogeneous collection property:
•Make the Collection property Stored False
• Make DefineProperties, LoadXXXProperty and StoreXXXProperty methods for the class that owns the collection |
Delphi
|
procedure DefineProperties(Filer: TFiler); override;
begin
inherited DefineProperties(Filer);
Filer.DefineProperty( 'HPresets',
LoadPresetsProperty, StorePresetsProperty,
Presets.Count > 0 );
end;
procedure LoadPresetsProperty(Reader: TReader);
var
Filer: TGSpecialFiler;
begin
Filer := TGSpecialFiler.Create(Reader);
try
Filer.ReadCollection(Presets);
finally
Filer.Free;
end;
end;
procedure StorePresetsProperty(Writer: TWriter);
var
Filer: TGSpecialFiler;
begin
Filer := TGSpecialFiler.Create(Writer);
try
Filer.WriteCollection(Presets);
finally
Filer.Free;
end;
end;
|