You are not logged in.
Pages: 1
hi,
i need to compare object for identity.
for identity i mean that if all properties of two object, these object are identity.
i think about using rtti with something like this:
function CompareObject(Object1, Object2: TObject): Boolean;
var aContext: TRttiContext;
aRtti: TRttiType;
aProperty: TRttiProperty;
Equality: Boolean;
begin
Equality := False;
if (Object1.ClassType = Object2.ClassType) then
begin
aContext := TRttiContext.Create;
try
aRtti := aContext.GetType(Object1.ClassType);
for aProperty in aRtti.GetProperties do
begin
//THIS NOT WORK. HOW TO COMPARE TWO TVALUE?
if (aProperty.GetValue(Object1) = aProperty.GetValue(Object2))
then
Equality := True
else
Equality := False;
end;
finally
aContext.Free;
end;
end;
Result := Equality;
end;
Is this a correct way or there is more simple one?
How can compare two TValue?
Maybe i must to cast TValue to his base type and then compare?
all suggestions are welcome!
thanks!
Emanuele
Offline
Pages: 1