Dann lass den TRTTIHelper ganz weg und mach das direkt in dem FuncInfoAttribute:
Delphi-Quellcode:
type
FuncInfoAttribute = class(TCustomAttribute)
private
FGL: string;
Fn_Var: Integer;
public
constructor Create(AGL: string; An_Var: Integer);
class function FindAttribute(Source: TClass): FuncInfoAttribute;
property GL: string read FGL;
property n_Var: Integer read Fn_Var;
end;
class function FuncInfoAttribute.FindAttribute(Source: TClass): FuncInfoAttribute;
var
context: TRttiContext;
myType: TRttiType;
attr: TCustomAttribute;
attributes: TArray<TCustomAttribute>;
begin
Result := nil;
context := TRttiContext.Create;
myType := context.GetType(Source);
if myType <> nil then begin
attributes := myType.GetAttributes;
for attr in attributes do begin
if attr is FuncInfoAttribute then begin
Result := FuncInfoAttribute(attr);
Break;
end;
end;
end;
end;
In den Gettern musst du dann die FindAttribute-Zeile so schreiben:
Delphi-Quellcode:
attr := FuncInfoAttribute.FindAttribute(ClassType);