The implements
directive allows you to delegate implementation of an interface to a property
in the implementing class. For example,
property
MyInterface: IMyInterface read FMyInterface implements
IMyInterface;
declares a property called MyInterface
that implements the interface IMyInterface.
The implements
directive must be the last specifier in the property declaration and can list
more than one interface, separated by commas. The delegate property
· must be of a class or interface type.
· cannot be an array property or have an index specifier.
· must have a read specifier. If the property uses a read
method, that method must use the default register calling convention and
cannot be dynamic (though it can be virtual) or specify the message
directive.
Note: The class you use to implement the delegated interface should derive from TAggregatedObject.
Delegating to an
interface-type property
Delegating to a class-type property
指示字implements允许再实现类中委托接口的实现到一个属性。例如,
property
MyInterface: IMyInterface read FMyInterface implements
IMyInterface;
这里声明了一个叫做MyInterface的属性,该属性用于实现接口IMyInterface。
在属性声明中,指示字implements必须是最后一个说明符并且可以列出多余一个接口,接口直接用逗号隔开。委托属性有如下限制:
· 必须是接口类型的类。
· 不能是数组属性或索引说明符。
· 必须具有read说明符。若属性使用read方法,则方法必须使用缺省的register调用约定且不能是动态(dynamic)方法(尽管可以是虚拟的)或指定了message指示字。
注意: 用于实现委托接口的类应起源于TAggregatedObject类。