2017-11-17 15 views
3

rtti로 클래스 속성을 가져올 수 있습니까? 아래 코드에 어떤 문제가 있습니까?rtti로 클래스 속성에 액세스하는 방법은 무엇입니까?

... 
type 
    TTest = class 
    private 
    class function GetCP: string; static; 
    public 
    class property CP: string read GetCP; 
    end; 

class function TTest.GetCP: string; 
begin 
    Result := 'ABC'; 
end; 
... 
procedure TForm1.Button5Click(Sender: TObject); 
var 
    oTest: TTest; 
    oType: TRttiType; 
begin 
    oTest := TTest.Create; 
    try 
    oType := TRttiContext.Create.GetType(oTest.ClassType); 
    ShowMessage(Length(oType.GetProperties).ToString); // oType.GetProperties = nil !!! 
    finally 
    oTest.Free; 
    end; 
end; 

TIA와 안부, 브란 코

답변

4

클래스 속성이 RTTI를 통해 액세스 할 수 없습니다.