Thread View: borland.public.delphi
2 messages
2 total messages
Started by masonwheeler
Mon, 21 Jul 2008 16:05
"is" operator equivalent for interfaces?
Author: masonwheeler
Date: Mon, 21 Jul 2008 16:05
Date: Mon, 21 Jul 2008 16:05
12 lines
1588 bytes
1588 bytes
I'm trying to make sure that any object passed to the write parameter of a property implements a certain interface. The obvious way for checking inheritance, the "is" operator, doesn't seem to work. Is there a different way to do it? procedure TEngineData.setEngine(const Value: TEngine); begin assert(value is IEngine); //compiler doesn't like this FEngine := Value; end; Any help would be appreciated.
Re: "is" operator equivalent for interfaces?
Author: BRoberts
Date: Fri, 01 Aug 2008 00:32
Date: Fri, 01 Aug 2008 00:32
19 lines
1993 bytes
1993 bytes
<masonwheeler@gmail.com> wrote in message news:bf992d9f-7587-4aca-95f7-3d71cdad88e5@t12g2000prg.googlegroups.com... > I'm trying to make sure that any object passed to the write parameter > of a property implements a certain interface. The obvious way for > checking inheritance, the "is" operator, doesn't seem to work. Is > there a different way to do it? > > procedure TEngineData.setEngine(const Value: TEngine); > begin > assert(value is IEngine); //compiler doesn't like this > FEngine := Value; > end; > > Any help would be appreciated. Interfaces can be bound dynamically at runtime. You can wrap an assignment using the AS operator in a try except and trap the error at runtime. Can you not simply use an iEngine parameter?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads