uses System.SysUtils, System.TypInfo, System.Rtti; type IWidget = interface procedure SetInstance(const Inst: T); end; TWidgetImpl = class(TInterfacedObject, IWidget) public procedure SetInstance(const Inst: T); end; { TWidgetImpl } procedure TWidgetImpl.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(Inst), []); end; end; type TObjInst = class public procedure Initialize; end; { TObjInst } procedure TObjInst.Initialize; begin WriteLn('TObjInst.Initialize'); end; type IIntfInst = interface(IInvokable) procedure Initialize; end; TIntfInstImpl = class(TInterfacedObject, IIntfInst) public procedure Initialize; end; { TIntfInstImpl } procedure TIntfInstImpl.Initialize; begin WriteLn('IIntfInst.Initialize'); end; var wo: IWidget; o: TObjInst; wi: IWidget; i: IIntfInst; begin wo := TWidgetImpl.Create; o := TObjInst.Create; wo.SetInstance(o); wi := TWidgetImpl.Create; i := TIntfInstImpl.Create; wi.SetInstance(i); ReadLn; end.