Explicit interface
Posted:
Sat Feb 08, 2014 7:16 pm
by nerdzero
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"?
Re: Explicit interface
Posted:
Sat Feb 08, 2014 7:28 pm
by nerdzero
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
Re: Explicit interface
Posted:
Mon Feb 10, 2014 1:57 am
by nerdzero
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?
Re: Explicit interface
Posted:
Mon Feb 10, 2014 3:07 am
by hopscc
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 )