newbee: How to do Interface deliegation

  • Thread starter Thread starter Kiran
  • Start date Start date
K

Kiran

Hi,

I am new to dotNet, as my background is from Delphi, I am always looking
for the way to do it that way :) sorry abt that.

I was looking for a way to delegate the interface supported by my class to
one of the contained class which we can do in Delphi using "implements"
keyword. OK to be more specific here is an example

Class CX : IX; and

now I have a class CY which is supposed to provide 2 interfaces IX & IY

class CY : IX, IY
{
public CX myCX;
.........
}

I want IX to be handled by a contained instance of CX in CY. but I do not
want to create a wrapper functions like this
........
public void MyIXMethod()
{
myCX.MyIXMethod();
}
.........

In Delphi I could simply delegate IX interface to myCX... is there any way
to do the same in C#.


regards
Kiran
 
Hi,

To me it sounds like you want CY to inherit CX;
class CY : CX, IY
{
}

Does this solve your problem?
 
Hi,

To me it sounds like you want CY to inherit CX;
class CY : CX, IY
{
}

Does this solve your problem?

not really, here CX an CY are not related... what if I have 4 or more
interfaces to be implimented this way.

When we design our BO we would like to
many a times we would like to delegate the responsibility to a contained
class, Inheritence is not always possible.

say I have
CA CB
^ ^
| |
CX : IX CY : IY


Now In I want CZ to support 2 interfaces IX and IY
CC
^
|
class CZ : CC, IX, IY
{
CX myCx;
CY myCy;
}

its lot eazy if i can some how say to CZ that both IX and IY interface of CZ
is actually handled by myCX and myCY contained object.

any way out in C# ??

Regards
Kiran
 
Back
Top