Reputation: 25
How can I pass a tkEnumeration as an RTTI Parameter to Method.Invoke.
I have tried
TMyEnums = (tsEnum1, tsEnum2);
ParameterList : Array of TValue;
lTypeInfo : PTypeInfo;
lTypeInfo := TypeInfo(TMyEnums);
ParameterList[0] := TValue.FromOrdinal(lTypeInfo, Integer(tsEnum1));
Method.Invoke(Object, ParameterList);
Which fails. Can Method.Invoke take a tkEnumeration parameter? Even if it did work - in my application at run time I do not know the type of the parameter so I can't obtain lTypeInfo;
Is there a way to obtain lTypeInfo from TRttiParameter?
I can get it for TRttiProperty as follows:
lTypeInfo := RTTIProperties[i].GetValue(SourceObject).TypeInfo
Is there an equivalent for TRttiParameter?
Upvotes: 1
Views: 1549
Reputation: 612954
You need to use reflection to find the type of the parameter:
I don't have a compiler here so I won't attempt to write code for this. Hopefully the outline above is enough for you.
Upvotes: 4