File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 7
7
Author : Kike Pérez
8
8
Version : 1.4
9
9
Created : 09/03/2018
10
- Modified : 03/04 /2020
10
+ Modified : 14/07 /2020
11
11
12
12
This file is part of QuickLib: https://github.com/exilon/QuickLib
13
13
@@ -76,6 +76,7 @@ TRTTI = class
76
76
class function FindClass (const aClassName: string): TClass;
77
77
class function CreateInstance <T>: T; overload;
78
78
class function CreateInstance (aBaseClass : TClass): TObject; overload;
79
+ class function CallMethod (aObject : TObject; const aMethodName : string; aParams : array of TValue) : TValue;
79
80
{ $ENDIF}
80
81
end ;
81
82
@@ -123,6 +124,7 @@ class function TRTTI.CreateInstance(aBaseClass : TClass): TObject;
123
124
rmethod: TRttiMethod;
124
125
rinstype: TRttiInstanceType;
125
126
begin
127
+ Result := nil ;
126
128
rtype := fCtx.GetType(aBaseClass);
127
129
for rmethod in rtype.GetMethods do
128
130
begin
@@ -136,6 +138,25 @@ class function TRTTI.CreateInstance(aBaseClass : TClass): TObject;
136
138
end ;
137
139
end ;
138
140
141
+ class function TRTTI.CallMethod (aObject : TObject; const aMethodName : string; aParams : array of TValue) : TValue;
142
+ var
143
+ rtype : TRttiType;
144
+ rmethod : TRttiMethod;
145
+ rinstype: TRttiInstanceType;
146
+ value : TValue;
147
+ begin
148
+ rtype := fCtx.GetType(aObject.ClassInfo);
149
+ for rmethod in rtype.GetMethods do
150
+ begin
151
+ if CompareText(rmethod.Name ,aMethodName) = 0 then
152
+ begin
153
+ rinstype := rtype.AsInstance;
154
+ value := rmethod.Invoke(rinstype.MetaclassType,aParams);
155
+ end ;
156
+
157
+ end ;
158
+ end ;
159
+
139
160
class destructor TRTTI.Destroy;
140
161
begin
141
162
fCtx.Free;
You can’t perform that action at this time.
0 commit comments