如何获取方法链接泛型类型的 TRTTIType
How to get TRTTIType for method linked generic type
我用的是Delphi10.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;
您正在寻找
ctx.GetType(TypeInfo(T))
我用的是Delphi10.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;
您正在寻找
ctx.GetType(TypeInfo(T))