我可以从字符串中获取 PTypeInfo 吗?
这可能会是“不”,但是有什么方法可以使用 Delphi 的 RTTI(旧式 RTTI 或 2010 扩展 RTTI)来传递包含类型名称的字符串,特别是枚举的名称类型,并让它给我该类型的 PTypeInfo 吗?我查看了 RTTI.pas 和 TypInfo.pas,没有看到任何可以做到这一点的函数,但我可能错过了一些东西。
我在寻找什么:
var
info: PTypeInfo;
begin
info := GetTypeInfoFromName('TComponentStyle');
end;
或者类似的东西。事实是,枚举类型的名称将被传入;它在编译时是不知道的。
This is probably going to be a "no", but is there any way I can use Delphi's RTTI, either old-school or the 2010 extended RTTI, to pass in a string containing the name of a type, specifically the name of an enumerated type, and have it give me the PTypeInfo for that type? I've looked through RTTI.pas and TypInfo.pas and I don't see any function that would do that, but I might have missed something.
What I'm looking for:
var
info: PTypeInfo;
begin
info := GetTypeInfoFromName('TComponentStyle');
end;
Or something like that. Thing is, the name of the enumerated type would be passed in; it wouldn't be known at compile time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下内容应与限定名称一起使用。
限定名称为:
UnitName.TypeName
The following should work with the qualified name.
Qualified Name is:
UnitName.TypeName