What do I have to do to implement my own stream, which uses custom compression routine, similiar to, for example, GZipStream?
I obviously have to subclass the Stream class, but which methods should be implemented by me and which methods can be left with their default implementations?
Basically speaking, there is a special part of documentation, but maybe there is a better and easier option?
Notes to Implementers
When implementing a derived class of Stream, you must provide implementations for the Read and Write methods. The asynchronous methods BeginRead, EndRead, BeginWrite, and EndWrite are implemented through the synchronous methods Read and Write. Similarly, your implementations of Read and Write will work correctly with the asynchronous methods. The default implementations of ReadByte and WriteByte create a new single-element byte array, and then call your implementations of Read and Write. When deriving from Stream, if you have an internal byte buffer, it is strongly recommended that you override these methods to access your internal buffer for substantially better performance. You must also provide implementations of CanRead, CanSeek, CanWrite, Flush, Length, Position, Seek, and SetLength.
Do not override the Close method, instead, put all of the Stream cleanup logic in the Dispose method. For more information, see Implementing a Dispose Method.
stackoveflowresults in better ways of solving problems and in many different things to think of. *Basically, the same thing happened here after @MarcGravell 's answer when I ended up thinking about usingthrowin methods likeSeek()and thinking about thesync/async-related design. - Yippie-Ki-Yay