I have a service hosted that have two interface A and B. I'm trying to implement proxy class for my client by using ClientBase. However, I don't know how to declare it.
This is what I thought it should be:
public class ServiceProxy : ClientBase<IA>, ClientBase<IB>, IA, IB
{
.......
}
Is that the right way to declare it ? If not, what would be the correct way ? Thank you.
This is one way to overcome the multiple inheritance problem, via composition by keeping an instance of each as a private property, and implementing interface methods/properties to access the private instances. (Can't be sure this will work for you in this case depending on what kind of factories are instantiating your service proxies.) In this case I'm guessing IA and IB might have some methods with identical signatures, in which case you will need to use explicit interface implementations to avoid conflicts.
public class ServiceProxy : IA, IB
{
private ClientBase<IA> IAProxy {get;set;}
private ClientBase<IB> IBProxy {get;set;}
public void IA.SomeInterfaceMethod(){
IAProxy.SomeInterfaceMethod();
}
public void IB.SomeInterfaceMethod(){
IBProxy.SomeInterfaceMethod();
}
}