PropType
Return the type of a property
Declaration
Source position: typinfo.pp line 883
function PropType(Instance: TObject; const PropName: string) : TTypeKind;
function PropType(AClass: TClass; const PropName: string) : TTypeKind;
Description
Proptype returns the type of the property PropName for a class. The class to be examined can be specified in one of 2 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. |
PropIsType | Check the type of a published property. |
Example
program example17;
{ This program demonstrates the PropType function }
{$mode objfpc}
uses rttiobj,typinfo;
Var
O : TMyTestObject;
begin
O:=TMyTestObject.Create;
Writeln('Property tests : ');
Write('PropType(O,BooleanField) : ');
Writeln(TypeNames[PropType(O,'BooleanField')]);
Write('PropType(Class,BooleanField) : ');
Writeln(TypeNames[PropType(O.ClassType,'BooleanField')]);
Write('PropType(O,ByteField) : ');
Writeln(TypeNames[PropType(O,'ByteField')]);
Write('PropType(Class,ByteField) : ');
Writeln(TypeNames[PropType(O.ClassType,'ByteField')]);
O.Free;
end.