 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Jul 21, 2008 4:05 pm Post subject: "is" operator equivalent for interfaces? |
|
|
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. |
|
| Back to top |
|
 |
BRoberts Guest
|
Posted: Fri Aug 01, 2008 5:32 am Post subject: Re: "is" operator equivalent for interfaces? |
|
|
<masonwheeler (AT) gmail (DOT) com> wrote in message
news:bf992d9f-7587-4aca-95f7-3d71cdad88e5 (AT) t12g2000prg (DOT) googlegroups.com...
| Quote: | 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? |
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group .
|