What is the easiest way to wrap a forward-only non-seekable source Stream (with CanSeek being false, e.g. an incoming network response) into a Stream that supports seeking, but does only read the same bytes from the source once?
Does .NET Standard (C#) offer any implementation of Stream which can be used for this or do I have to write this functionality by myself?
I can imagine an implementation of Stream which gets the source Stream at construction, reads from it and stores bytes that are read for the first time in a cache or buffer which is then used for each subsequent read of the same bytes.
I don't want to wait for the source Stream to be read completely before accessing the wrapped Stream (because it's very large). Therefore copying the source into a local buffer before accessing the buffer is not what I want.