November 2019
Beginner to intermediate
674 pages
15h
English
Before we can use an attribute, we have to declare it. To declare an attribute, we have to derive it from a special class, TCustomAttribute:
type SpecialClassAttribute = class(TCustomAttribute) end;
To use this attribute, we annotate a Delphi entity (for example a class) by enclosing the attribute name in square brackets:
type [SpecialClassAttribute] TThisIsMySpecialClass = class end;
The Delphi compiler allows us to shorten the attribute name if it ends with Attribute:
type [SpecialClass] TThisIsAnotherSpecialClass = class end;
A code can only use an attribute if the ...
Read now
Unlock full access