BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"is" operator equivalent for interfaces?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Mon Jul 21, 2008 4:05 pm    Post subject: "is" operator equivalent for interfaces? Reply with 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.
Back to top
BRoberts
Guest





PostPosted: Fri Aug 01, 2008 5:32 am    Post subject: Re: "is" operator equivalent for interfaces? Reply with quote



<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
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General) All times are GMT
Page 1 of 1

 
 


Powered by phpBB © 2001, 2006 phpBB Group
.