I'm writing an application that creates catalogs of files. Currently the catalog information is stored in an XML file, but I'm trying to abstract the interface to a catalog to allow for other future storage mechanisms such as a single ZIP file, SQL server, or HTTP server. So rather than returning a file path the abstract Catalog class returns files as byte Streams. Thus allowing the source of a file to be a disk, but also for files coming from a database or a web server. See my previous related question.
However, the root Stream class includes Streams with different capabilities. Some streams can only be read, others can only be written to. Still some streams support seeking, while other streams do not.
Is there anyway to restrict the capabilities of the stream returns by a property or method? For example my Catalog class looks something like this.
public abstract class Catalog
{
...
public abstract Stream File
{
get;
}
...
}
Is there someway to ensure that File
will always return a readable stream that supports seeking?