Forums

Explicit interface

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Explicit interface

Postby nerdzero » Sat Feb 08, 2014 7:16 pm

I'm trying to implement two interfaces coming from a lib with one class but I think I just got stuck because I can't explicitly mark a property as implementing an interface. Here's an example to illustrate the issue:

class DoesBoth implements IFoo, IBar
get someProp # what do I do?
return this

interface IFoo
get someProp as IFoo

interface IBar
get someProp as IBar


Am I stuck? Is there any kind of workaround maybe using "partial"?
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Explicit interface

Postby nerdzero » Sat Feb 08, 2014 7:28 pm

Okay, nevermind. This could work:

class DoesFoo implements IFoo
get someProp as IFoo
return this

class DoesBoth inherits DoesFoo implements IBar
get someProp as IBar is new
return this

interface IFoo
get someProp as IFoo

interface IBar
get someProp as IBar
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Explicit interface

Postby hopscc » Sun Feb 09, 2014 5:01 am

old defect, see ticket:262
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Explicit interface

Postby nerdzero » Mon Feb 10, 2014 1:57 am

Cool, but the patch is a little tough for me to follow. What does do it in terms of accessibility from the class? In C# the member becomes private (I think) and you need to cast to the interface type to access it. VB lets the implementing member have a different name, let's you implement multiple members with declaration, and can have whatever accessibility (I think). What's the expected behavior for Cobra with the patch on that ticket?
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Explicit interface

Postby hopscc » Mon Feb 10, 2014 3:07 am

From memory it allows you to declare the property implementation as supporting whatever particular interface you need it to ...
the accessibility is as declared(or defaulted to )
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 54 guests