I want to define a set of classes that collect and persist data. I want to call them either on-demand basis, or in a chain-of-responsibility fashion, as the caller pleases.
To support the chaining, I have declared my interface like so:
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 the T's and K's for each concrete types will be different. If I give it like this:
IDataManager<T, K> NextDataManager;
I assume that the calling code will only be able to chain types that have the same T's and K's. Is there a way I can have it chain any type of IDataManager?
One thing that occurs to me is to have IDataManager inherit from a non-generic IDataManager like so:
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;
}
Is this going to work?