Home Returning an ObjectList from RTTI in delphi
Reply: 0

Returning an ObjectList from RTTI in delphi

user1048 Published in May 25, 2018, 9:05 am

i'm calling method inside an object and i'm trying to stay very dynamic in the way i'm doing it and i came to a problem where my return type is a list of some objects, i thought about using TObjectList the problem now is that rtti returns a TValue and i don't fully understand how i can convert it to TObjectList. I thought casting the TValue as TObject since theoritically TObjectList is an object but it didn't work. Do you guys have any idea how i can possibly achieve this?

That's the function i'm speaking about.

   function TMyClass.ExecMethodAndRet(MethodName: string;
      Args: array of TValue): TObjectList<TObject>;
     R : TRttiContext;
     T : TRttiType;
     M : TRttiMethod;
      T := R.GetType(FMyObject.ClassInfo);
      for M in t.GetMethods do
        if (m.Parent = t) and (UpperCase(m.Name) = UpperCase(MethodName))then
          result := M.Invoke(FMyObject, Args); <- problem here can't cast to TObjectList
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.478317 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO