I have a Service with a business object (bo), that implements an interface. The bo implements an interface too. How can I declare an interface, that describes the service and also the bo?
Here some Code:
// Business object with interface
public interface IBoBase { }
public class Bo : IBoBase { }
// Service with interface
public interface IService<TBo> where TBo : IBoBase
{
TBo Get();
void Set(TBo bo);
}
public class Service : IService<Bo>
{
private Bo _bo;
public Bo Get(){return _bo;}
public void Set(Bo bo) { _bo = bo; }
}
// Usage
public class SubService
{
private readonly List<IService<IBoBase>> _injectedService;
public SubService(Service injectedService)
{
_injectedService = new List<IService<IBoBase>>
{
injectedService // cannot cast to IService<IBoBase> ... why?
};
}
}
Does anyone have an idea, how to design the interface, so I can use it like described in the code example?