I want to define a set of classes that collect and store data. I want to call them on demand or on the principle of a chain of responsibility, as the caller likes it.
To maintain the chain, I declared my interface as follows:
interface IDataManager<T, K>
{
T GetData(K args);
void WriteData(Stream stream);
void WriteData(T data, Stream stream);
IDataCollectionPolicy Policy;
IDataManager<T, K> NextDataManager;
}
But T and K for each particular type will be different. If I give it like this:
IDataManager<T, K> NextDataManager;
I assume that the calling code can only bind types that have the same T and K. Is there a way I can bind it to any type of IDataManager?
One thing that arises for me is to inherit the IDataManager from the non-generic IDataManager as follows:
interface IDataManager { }
interface IDataManager<T, K>: IDataManager
{
T GetData(K args);
void WriteData(Stream stream);
void WriteData(T data, Stream stream);
IDataCollectionPolicy Policy;
IDataManager NextDataManager;
}
Will this work?
source
share