Can someone help me with xe7 and rtti?
Can someone help me with xe7 and rtti?
I need to know the tClassType of a not created Object i.e.
var
myObject:tMyComponent;
begin
// myObject is only declared but not created at this time
TestFunction(myObject);
end;
As you can see, the myObject is not created at that moment, but in the TestFunction i need to know the ClassType of the given Object to call its constructor via RTTI ...
procedure TestFunction(vObject:tObject);
var
ctx : TRttiContext;
rt : TRttiType;
begin
ctx := TRttiContext.Create();
rt := ctx.GetType( vObject); << problem here because vObject was not created ..
......
-snip -
end;
Thanks a lot for some help ...
I need to know the tClassType of a not created Object i.e.
var
myObject:tMyComponent;
begin
// myObject is only declared but not created at this time
TestFunction(myObject);
end;
As you can see, the myObject is not created at that moment, but in the TestFunction i need to know the ClassType of the given Object to call its constructor via RTTI ...
procedure TestFunction(vObject:tObject);
var
ctx : TRttiContext;
rt : TRttiType;
begin
ctx := TRttiContext.Create();
rt := ctx.GetType( vObject); << problem here because vObject was not created ..
......
end;
Thanks a lot for some help ...
What you don't seem to grasp is that until you have an instance, you cannot ask what type that instance is.
ReplyDeleteYusuf Zorlu If you go down the path that Simon Stuart suggests, you can get the information without having an instance, but it may be that for multiple class hierarchies without a common root - Generics will be less work.
ReplyDeleteLars Fosdal Simon Stuart Thanks a lot for your introductions / help. Will post here if i have found a working solution. Nice "programmings" ...
ReplyDelete