IMHO, in this case you must define three types. One for the interface and the third for multiple inheritance:
IInterfaceA = interface
procedure A;
end;
IInterfaceB = interface
procedure B;
end;
TiA = class(TInterfacedObject, IInterfaceA)
procedure A;
end;
TiB = class(TInterfacedObject, IInterfaceB)
procedure B;
end;
TMyObject = class(TInterfacedObject, IInterfaceA, IInterfaceB)
private
_iA : IInterfaceA;
_iB : IInterfaceB;
function getiA : IInterfaceA;
function getiB : IInterfaceB;
public
property iA : IInterfaceA read getiA implements IInterfaceA;
property iB : IInterfaceB read getiB implements IInterfaceB;
end;
{.....}
{ TMyObject }
function TMyObject.getiA: IInterfaceA;
begin
if not Assigned(_iA) then _iA := TIA.Create;
Result := _iA;
end;
function TMyObject.getiB: IInterfaceB;
begin
if not Assigned(_iB) then _iB := TIB.Create;
Result := _iB;
end;
source
share