mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-10 19:45:59 +02:00
* Add IsInstanceOf
This commit is contained in:
parent
972b961f2b
commit
a9ff6272f6
@ -229,6 +229,7 @@ type
|
|||||||
function GetArrayElement(AIndex: SizeInt): TValue;
|
function GetArrayElement(AIndex: SizeInt): TValue;
|
||||||
procedure SetArrayElement(AIndex: SizeInt; constref AValue: TValue);
|
procedure SetArrayElement(AIndex: SizeInt; constref AValue: TValue);
|
||||||
function IsType(aTypeInfo: PTypeInfo): boolean; inline;
|
function IsType(aTypeInfo: PTypeInfo): boolean; inline;
|
||||||
|
function IsInstanceOf(aClass : TClass): boolean; inline;
|
||||||
function TryCast(aTypeInfo: PTypeInfo; out aResult: TValue; const aEmptyAsAnyType: Boolean = True): Boolean;
|
function TryCast(aTypeInfo: PTypeInfo; out aResult: TValue; const aEmptyAsAnyType: Boolean = True): Boolean;
|
||||||
function Cast(aTypeInfo: PTypeInfo; const aEmptyAsAnyType: Boolean = True): TValue; overload;
|
function Cast(aTypeInfo: PTypeInfo; const aEmptyAsAnyType: Boolean = True): TValue; overload;
|
||||||
{$ifndef NoGenericMethods}
|
{$ifndef NoGenericMethods}
|
||||||
@ -1844,6 +1845,19 @@ begin
|
|||||||
Result:=IsDateTimeType(TypeInfo);
|
Result:=IsDateTimeType(TypeInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TValue.IsInstanceOf(aClass : TClass): boolean;
|
||||||
|
|
||||||
|
var
|
||||||
|
Obj : TObject;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=IsObject;
|
||||||
|
if not Result then
|
||||||
|
exit;
|
||||||
|
Obj:=AsObject;
|
||||||
|
Result:=Assigned(Obj) and Obj.InheritsFrom(aClass);
|
||||||
|
end;
|
||||||
|
|
||||||
{$ifndef NoGenericMethods}
|
{$ifndef NoGenericMethods}
|
||||||
generic function TValue.IsType<T>:Boolean;
|
generic function TValue.IsType<T>:Boolean;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user