pra*_*mer 4 delphi interface rtti delphi-2010
我有一个TGUID变量,我想通过Rtti将其"转换"为描述该接口的PTypeInfo.
AGUID := StringToGUID('{19BB9F78-1FB1-4B0F-B691-82EE5CD7A941}');
.. transform AGUID to PTypeInfo ..
AInterface = GlobalContainer.Resolve( <PTypeInfo> expected);
Run Code Online (Sandbox Code Playgroud)
Delphi 2010+
function GetInterfaceTypeInfo(const GUID: TGUID): PTypeInfo;
var
Ctx: TRttiContext;
AType: TRttiType;
begin
Result := nil;
Ctx := TRttiContext.Create;
try
for AType in Ctx.GetTypes do
if (AType.TypeKind = tkInterface) and IsEqualGUID(GetTypeData(AType.Handle)^.Guid, GUID) then
begin
Result := AType.Handle;
Break;
end;
finally
Ctx.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
479 次 |
最近记录: |