2017-11-17 22 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を介してアクセスすることができません。