如何获得方法链接的泛型的TRTTIType

问题描述 投票:1回答:1

我使用Delphi 10.3。获取实例变量的相应TRTTIType是一种例程。但是有什么方法可以填补这里标记为*缺少代码*的空白:

function getGenericTypeName<T> : string;
var
  ctx : TRTTIContext;
  aRT : TRTTIType;
begin
  ctx := TRTTIContext.Create;
  try
    aRT := *** missing code for T *** // Get the TRTTIType for type T
    result := aRT.Name;
  finally
    ctx.Free;
  end;
end;
delphi rtti delphi-10.3-rio
1个回答
4
投票

您正在寻找

ctx.GetType(TypeInfo(T))
© www.soinside.com 2019 - 2024. All rights reserved.