I've become quite familiar with Dependency Injection and the power of loosely-coupled components. When I sought to enhance or build on that for educational purposes I stumbled across a problem:
public interface IReader<TParameter, TOutput>
{
TOutput Read(TParameter parameter);
}
public class Customer : IReader<int, CustomerModel>
{
public CustomerModel Read(int parameter)
{
// Implementation...
}
}
The problem comes when you attempt to use Dependency Injection. I attempted:
public class Reader<TParameter, TOutput>
{
private IReader<TParameter, TOutput> reader;
public Reader(IReader<TParameter, TOutput> reader)
{
// Link through Constructor...
}
}
That doesn't work, but at this stage how can you implement and perform Dependency Injection when a generic is involved at this level? Is it even possible?