Search code examples
delphigenericsrtti

method call of a generic list with RTTI


I don't know how to do this:

Having this objects:

TMyObject = class;

TMyList<T: TMyObject> = class(TList<T>)
public
     function Execute(aParam1, aParam2:string):boolean;
end;

TMyOtherObject = class(TMyObject)

TMyOtherList = class(TMyList<TMyOtherObject>);

How can I execute the "execute" function via rtti if I receive a TMyOtherList object in a function param as an TObject?

Thanks.


Solution

  • Don't bother with RTTI, just use a cast:

    (aObject as TMyOtherList).Execute(param1, param2);
    

    If casting is not an option then use an interface.