Ich brauch für eine (sehr umfangreiche History) eine so oder ähnliches Konstruktion. Kann man das so machen?
Delphi-Quellcode:
TMyLists = class
private
FPath: string;
FValue: TMyList;
FFileNames: TStringList;
function GetMyLists(I: integer): TMyList;
public
function Count: integer;
function Add(Value: TMyList) : integer;
property MyLists[I: integer]: TMyList read GetMyLists;
constructor Create;
destructor Destroy; override;
end;
..
constructor TMyLists.Create;
var
S: string;
begin
S := FormatDateTime('ddmmyyyyhhnnsszzz', Now);
FPath := ExtractFileName(ParamStr(0)) + 'Temp\' + S;
ForceDirectories(FPath);
FValue := TMyList.Create;
FFileNames := TStringList.Create;
end;
destructor TMyLists.Destroy;
begin
DeletePath(FPath);
FValue.Free;
inherited Destroy;
end;
function TMyLists.Count: integer;
begin
Result := FFileNames.Count;
end;
function TMyLists.GetMyLists(I: integer): TMyList;
begin
FValue.LoadFromFile(FFileNames[I]);
Result := FValue;
end;
function TMyLists.Add(Value: TMyList) : integer;
begin
Result := Count;
FFileNames.Add(FPath + IntToStr(Count));
Value.SaveToFile(FFileNames[Count - 1]);
end;