Class PooledMemoryBufferStream

Readable and writeable stream implementation backed by a pooled memory area

Inheritance
System.Object
System.MarshalByRefObject
System.IO.Stream
PooledMemoryBufferStream
Implements
System.IDisposable
Inherited Members
System.IO.Stream.Null
System.IO.Stream.CopyToAsync(System.IO.Stream)
System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32)
System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32, System.Threading.CancellationToken)
System.IO.Stream.CopyTo(System.IO.Stream)
System.IO.Stream.CopyTo(System.IO.Stream, System.Int32)
System.IO.Stream.FlushAsync()
System.IO.Stream.FlushAsync(System.Threading.CancellationToken)
System.IO.Stream.CreateWaitHandle()
System.IO.Stream.BeginRead(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
System.IO.Stream.EndRead(System.IAsyncResult)
System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32)
System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
System.IO.Stream.BeginWrite(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
System.IO.Stream.EndWrite(System.IAsyncResult)
System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32)
System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
System.IO.Stream.ReadByte()
System.IO.Stream.WriteByte(System.Byte)
System.IO.Stream.Synchronized(System.IO.Stream)
System.IO.Stream.ObjectInvariant()
System.IO.Stream.CanTimeout
System.IO.Stream.ReadTimeout
System.IO.Stream.WriteTimeout
System.MarshalByRefObject.MemberwiseClone(System.Boolean)
System.MarshalByRefObject.GetLifetimeService()
System.MarshalByRefObject.InitializeLifetimeService()
System.MarshalByRefObject.CreateObjRef(System.Type)
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.BaseLibrary.IO
Assembly: EPiServer.BaseLibrary.dll
Version: 8.11.0
Syntax
public class PooledMemoryBufferStream : Stream, IDisposable

Constructors

PooledMemoryBufferStream(MemoryBufferPool)

Initializes a new instance of the PooledMemoryBufferStream class

Declaration
public PooledMemoryBufferStream(MemoryBufferPool pool)
Parameters
Type Name Description
MemoryBufferPool pool

Use this pool to allocate memory from

Properties

CanRead

True if not closed

Declaration
public override bool CanRead { get; }
Property Value
Type Description
System.Boolean
Overrides
System.IO.Stream.CanRead

CanSeek

True if not closed

Declaration
public override bool CanSeek { get; }
Property Value
Type Description
System.Boolean
Overrides
System.IO.Stream.CanSeek

CanWrite

True if not closed

Declaration
public override bool CanWrite { get; }
Property Value
Type Description
System.Boolean
Overrides
System.IO.Stream.CanWrite

Length

The length of the stream. (How many bytes you can read from position 0).

Declaration
public override long Length { get; }
Property Value
Type Description
System.Int64
Overrides
System.IO.Stream.Length

Position

Gets or sets the next position to read or write from or to.

Declaration
public override long Position { get; set; }
Property Value
Type Description
System.Int64
Overrides
System.IO.Stream.Position

Methods

Close()

Close the stream and Dispose() of the memory buffers

Declaration
public override void Close()
Overrides
System.IO.Stream.Close()

Dispose()

Releases all resources used by the System.IO.Stream.

Declaration
public void Dispose()

Dispose(Boolean)

Clean up. This is important since we want to keep track of re-usable buffers from the backing memory store.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing

true of called via Dispose(), false if called by framework Finalize()

Overrides
System.IO.Stream.Dispose(System.Boolean)

Finalize()

Releases unmanaged resources and performs other cleanup operations before the PooledMemoryBufferStream is reclaimed by garbage collection.

Declaration
protected void Finalize()

Flush()

Do nothing

Declaration
public override void Flush()
Overrides
System.IO.Stream.Flush()

Read(Byte[], Int32, Int32)

Read from the stream

Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type Name Description
System.Byte[] buffer

Where to put the result

System.Int32 offset

Offset into the buffer to place the result

System.Int32 count

How many bytes to read

Returns
Type Description
System.Int32

The actual number of bytes read. 0 for end of file.

Overrides
System.IO.Stream.Read(System.Byte[], System.Int32, System.Int32)

Seek(Int64, SeekOrigin)

Set the position of next read and write

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type Name Description
System.Int64 offset

Whence the seek is relative to

System.IO.SeekOrigin origin

The amount to seek from the offset

Returns
Type Description
System.Int64

The new position

Overrides
System.IO.Stream.Seek(System.Int64, System.IO.SeekOrigin)
Remarks

No actual allocation of space is done by Seeking

SetLength(Int64)

Set the length of stream.

Declaration
public override void SetLength(long value)
Parameters
Type Name Description
System.Int64 value

The length

Overrides
System.IO.Stream.SetLength(System.Int64)
Remarks

No actual allocation of space is done, this just limits how far you can read

Write(Byte[], Int32, Int32)

Write to the stream

Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type Name Description
System.Byte[] buffer

The buffer to write from

System.Int32 offset

The offset in the buffer to start from

System.Int32 count

The number of bytes to write

Overrides
System.IO.Stream.Write(System.Byte[], System.Int32, System.Int32)

Implements

System.IDisposable

Extension Methods