In this method:
-------------------------
procedure TWidgetImpl<T>.SetInstance(const Inst: T);
var
ctx: TRttiContext;
typ: TRttiType;
m: TRttiMethod;
begin
typ := ctx.GetType(TypeInfo(T));
m := typ.GetMethod('Initialize');
if (Assigned(m)) then
begin
m.Invoke(TValue.From<T>(Inst), []);
end;
end;
--------------
I have a private var (fSubscriber) of T and I get access like this:
typ := ctx.GetType((fSubscriber as TObject).ClassInfo);
....
m.Invoke((fSubscriber as TObject),[]);
Your code is different in these two lines. I think I tried to use TypeInfo and didn't work nicely if I recall correctly.
Is it wrong what I am doing?
Thanks