Interface helpers or delegating interface parent

Posted by Craig Peterson on Stack Overflow See other posts from Stack Overflow or by Craig Peterson
Published on 2010-04-20T21:28:43Z Indexed on 2010/04/20 21:33 UTC
Read the original article Hit count: 273

Filed under:
|

If I have an existing IInterface descendant implemented by a third party, and I want to add helper routines, does Delphi provide any easy way to do so without redirecting every interface method manually? That is, given an interface like so:

IFoo = interface
  procedure Foo1;
  procedure Foo2;
  ...
  procedure FooN;
end;

Is anything similar to the following supported?

IFooHelper = interface helper for IFoo
  procedure Bar;
end;

or

IFooBar = interface(IFoo)
  procedure Bar;
end;

TFooBar = interface(TInterfacedObject, IFoo, IFooBar)
private
  FFoo: IFoo;
public
  procedure Bar;
  property Foo: IFoo implements IFoo;
end;

I'm specifically wondering about ways to that allow me to always refer to IFoo, IFooBar, or TFooBar, without switching between them, and without adding all of IFoo's methods to TFooBar.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about interfaces