具体操作是这样的 获得某个类的方法 属性 已经能够获得属性的类型了 现在剩下方法的类型没办法获取。 function TatProperties.AddByRTTI(APropInfo: PPropInfo): TatProperty; begin result := TatProperty(inherited Add); with result do begin FName := string(APropInfo^.Name); FDataType := MapTatTypeKind(APropInfo^.PropType^^.Kind); if Assigned(APropInfo^.GetProc) then FGetter := GenericProc(RTTIGetterProc); if Assigned(APropInfo^.SetProc) then FSetter := GenericProc(RTTISetterProc); FPropInfo := APropInfo; FPropertyClass := GetTypeData(FPropInfo.PropType^)^.ClassType; FXName := FPropInfo.PropType^.Name; //获得属性值的类型的名称 例如:string end; end;
function TatProperties.AddByRTTI(APropInfo: PPropInfo): TatProperty;
begin
result := TatProperty(inherited Add);
with result do
begin
FName := string(APropInfo^.Name);
FDataType := MapTatTypeKind(APropInfo^.PropType^^.Kind);
if Assigned(APropInfo^.GetProc) then
FGetter := GenericProc(RTTIGetterProc);
if Assigned(APropInfo^.SetProc) then
FSetter := GenericProc(RTTISetterProc);
FPropInfo := APropInfo;
FPropertyClass := GetTypeData(FPropInfo.PropType^)^.ClassType;
FXName := FPropInfo.PropType^.Name; //获得属性值的类型的名称 例如:string
end;
end;