JGR MSTS Editors and Tools
BufferedInMemoryStream Class

[This is preliminary documentation and is subject to change.]

A Stream which buffers both reads and writes in memory (as a MemoryStream).
Declaration Syntax
C#Visual BasicVisual C++
public class BufferedInMemoryStream : Stream
Public Class BufferedInMemoryStream _
	Inherits Stream
public ref class BufferedInMemoryStream : public Stream
All MembersConstructorsMethodsPropertiesFields

__identity()()()() (Inherited from MarshalByRefObject.)
__RaceSetServerIdentity(ServerIdentity) (Inherited from MarshalByRefObject.)
__ResetServerIdentity()()()() (Inherited from MarshalByRefObject.)
_asyncActiveCount()()()() (Inherited from Stream.)
_asyncActiveEvent()()()() (Inherited from Stream.)
_CloseAsyncActiveEvent(Int32) (Inherited from Stream.)
_readDelegate()()()() (Inherited from Stream.)
_writeDelegate()()()() (Inherited from Stream.)
BeginRead(array<Byte>[]()[][], Int32, Int32, AsyncCallback, Object) HostProtectionAttribute. (Inherited from Stream.)
BeginWrite(array<Byte>[]()[][], Int32, Int32, AsyncCallback, Object) HostProtectionAttribute. (Inherited from Stream.)
CanCastToXmlType(String, String) (Inherited from MarshalByRefObject.)
CanRead (Overrides Stream.CanRead.)
CanSeek (Overrides Stream.CanSeek.)
CanTimeout (Inherited from Stream.)
CanWrite (Overrides Stream.CanWrite.)
Close()()()() (Overrides Stream.Close()()()().)
CreateObjRef(Type) (Inherited from MarshalByRefObject.)
CreateWaitHandle()()()() Obsolete. (Inherited from Stream.)
Dispose()()()() (Inherited from Stream.)
Dispose(Boolean) (Inherited from Stream.)
EndRead(IAsyncResult) (Inherited from Stream.)
EndWrite(IAsyncResult) (Inherited from Stream.)
Equals(Object) (Inherited from Object.)
FieldGetter(String, String, Object%) (Inherited from Object.)
FieldSetter(String, String, Object) (Inherited from Object.)
Finalize()()()() (Inherited from Object.)
Flush()()()() (Overrides Stream.Flush()()()().)
GetComIUnknown(Boolean) (Inherited from MarshalByRefObject.)
GetFieldInfo(String, String) (Inherited from Object.)
GetHashCode()()()() (Inherited from Object.)
GetLifetimeService()()()() (Inherited from MarshalByRefObject.)
GetType()()()() (Inherited from Object.)
Identity()()()() (Inherited from MarshalByRefObject.)
InitializeLifetimeService()()()() (Inherited from MarshalByRefObject.)
InvokeMember(String, BindingFlags, Binder, array<Object>[]()[][], array<ParameterModifier>[]()[][], CultureInfo, array<String>[]()[][]) (Inherited from MarshalByRefObject.)
IsInstanceOfType(Type) (Inherited from MarshalByRefObject.)
Length (Overrides Stream.Length.)
MemberwiseClone(Boolean) (Inherited from MarshalByRefObject.)
MemberwiseClone()()()() (Inherited from Object.)
Position (Overrides Stream.Position.)
Read(array<Byte>[]()[][], Int32, Int32) (Overrides Stream.Read(array<Byte>[]()[][], Int32, Int32).)
ReadByte()()()() (Inherited from Stream.)
ReadTimeout (Inherited from Stream.)
Seek(Int64, SeekOrigin) (Overrides Stream.Seek(Int64, SeekOrigin).)
SetLength(Int64) (Overrides Stream.SetLength(Int64).)
ToString()()()() (Inherited from Object.)
Write(array<Byte>[]()[][], Int32, Int32) (Overrides Stream.Write(array<Byte>[]()[][], Int32, Int32).)
WriteByte(Byte) (Inherited from Stream.)
WriteTimeout (Inherited from Stream.)

Treat this stream like any other; Read(array<Byte>[]()[][], Int32, Int32), Write(array<Byte>[]()[][], Int32, Int32), Seek(Int64, SeekOrigin) all work normally (or close enough) in most cases. There are some specific exceptions, which shouldn't be a problem normally, outlined below.

When reading, if the underlying stream does not report a length itself, the value reported by Length represents the amount buffered. The BufferedInMemoryStream attempts to keep the Length beyond the current seek location at all times.

when reading, Seek(Int64, SeekOrigin) will operate normally but only within the data already buffered; attempts to seek beyond this will raise an exception. There is no way to force a certain amount of data to be buffered.

When writing, Flush()()()() is a no-op and SetLength(Int64) is not implemented. None of the Stream methods and properties will cause data to be written to the underlying stream.

When writing, to cause all buffered data to be written to the underlying stream, call RealFlush()()()(). This non-standard behavior is due to unfortunate existing code which calls Flush()()()() after writing to a Stream, which would otherwise cause us a problem with write-once underlying streams (which we're specifically trying to support here).

Inheritance Hierarchy

Assembly: JGR.IO (Module: JGR.IO) Version: 0.5.4008.31681