I have an interface defined as:
public interface IClientFileImporter
{
bool CanImport(Stream stream);
int Import(Stream stream);
}
The idea is to take any file stream and run it through a series of implementations of this interface to determine which one should handle the file. Some of the implementations may look for a certain header row, while others may look for a certain byte sequence, etc...
My question is, is it OK to pass a stream around like this as long as I never close it? Each method would have to be responsible for resetting the stream to position 0 if necessary, but are there any other potential issues (aside from thread safety)? This code really smells, IMO, but I'm not sure of a better way to do it.