PropIsType
Check the type of a published property.
Declaration
Source position: typinfo.pp line 885
function PropIsType(Instance: TObject; const PropName: string;
TypeKind: TTypeKind) : Boolean;
function PropIsType(AClass: TClass; const PropName: string;
TypeKind: TTypeKind) : Boolean;
Description
PropIsType returns True if the property with name PropName has type TypeKind. It returns False otherwise. The class to be examined can be specified in one of two ways:
- AClass
- A class pointer.
- Instance
- An instance of the class.
Errors
No checks are done to ensure Instance or AClass are valid pointers.Specifying an invalid property name in PropName will result in an EPropertyError exception.
See also
Name | Description |
---|---|
IsPublishedProp | Check whether a published property exists. |
IsStoredProp | Check whether a property is stored. |
PropType | Return the type of a property |
Example
program example16;
{ This program demonstrates the PropIsType function }
{$mode objfpc}
uses rttiobj,typinfo;
Var
O : TMyTestObject;
begin
O:=TMyTestObject.Create;
Writeln('Property tests : ');
Write('PropIsType(O,BooleanField,tkBool) : ');
Writeln(PropIsType(O,'BooleanField',tkBool));
Write('PropIsType(Class,BooleanField,tkBool) : ');
Writeln(PropIsType(O.ClassType,'BooleanField',tkBool));
Write('PropIsType(O,ByteField,tkString) : ');
Writeln(PropisType(O,'ByteField',tkString));
Write('PropIsType(Class,ByteField,tkString) : ');
Writeln(PropIsType(O.ClassType,'ByteField',tkString));
O.Free;
end.