Hallo,
muß es unbedingt
RTTI sein? Vielleicht kann man das Problem auch mit einer Array-Property lösen:
Delphi-Quellcode:
type
TLizenzen = class (TObject)
private
FID : TStringList;
function GetLizenz (const ID: string): Boolean;
procedure SetLizenz (const ID: string; Value: Boolean);
public
constructor Create;
destructor Destroy;
override;
property Lizenz [const ID: string]: Boolean
read GetLizenz write SetLizenz; default;
end;
constructor TLizenzen.Create;
begin
inherited;
FID := TStringList.Create;
FID.Sorted := True;
FID.Add('M110100');
FID.Add('M110120');
FID.Add('M110140');
FID.Add('M110200');
end;
destructor TLizenzen.Destroy;
begin
FID.Free;
inherited;
end;
function TLizenzen.GetLizenz (const ID: string): Boolean;
var index : Integer;
begin
index := FID.IndexOf(ID);
Result := (index >= 0) and Assigned(FID.Objects[index]);
end;
procedure TLizenzen.SetLizenz (const ID: string; Value: Boolean);
var index : Integer;
begin
index := FID.IndexOf(ID);
if (index >= 0) then
FID.Objects[index] := Pointer(Ord(Value));
end;
procedure TestLIC;
var LIC : TLizenzen;
Flag : Boolean;
begin
LIC := TLizenzen.Create;
Flag := LIC['Hallo'];
LIC['M110140'] := True;
Flag := LIC['M110140'];
LIC['M110140'] := False;
Flag := LIC['M110140'];
LIC.Free;
end;
Gruß Hawkeye