Einzelnen Beitrag anzeigen

Benutzerbild von s.h.a.r.k
s.h.a.r.k

Registriert seit: 26. Mai 2004
3.159 Beiträge
 
#4

Re: Referenz auf Recordtyp, wie TClass für Klassen

  Alt 8. Mär 2010, 11:25
Der Aufbau ist nicht das Problem, ich wollte vielmehr folgendes machen, was aber bisher nicht klappt
Delphi-Quellcode:
RString = record
  { blub }
end;

// ---------------
var
  context : TRttiContext;
  typeInfo : TRttiType;
  prop : TRttiProperty;
  recordName : String
begin
  context := TRttiContext.Create();
  typeInfo := context.GetType(obj.ClassType);

  prop := typeInfo.GetProperty('RecordVar');

  if (prop.GetType() = RString) then // GetType wäre die gewünschte Methode, die den Record-Typen liefert
  begin
    { ... }
  end;
end;
Ich hoffe, damit ist klar, was ich meine.
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
  Mit Zitat antworten Zitat