RecyclableMemoryStreamManager.GetStream method (1 of 14)

December 6, 2023 · View on GitHub

Retrieve a new RecyclableMemoryStream object with no tag and a default initial capacity.

public RecyclableMemoryStream GetStream()

Return Value

A RecyclableMemoryStream.

See Also


RecyclableMemoryStreamManager.GetStream method (2 of 14)

Retrieve a new RecyclableMemoryStream object with the contents copied from the provided buffer. The provided buffer is not wrapped or used after construction.

public RecyclableMemoryStream GetStream(byte[] buffer)
parameterdescription
bufferThe byte buffer to copy data from.

Return Value

A RecyclableMemoryStream.

Remarks

The new stream's position is set to the beginning of the stream when returned.

See Also


RecyclableMemoryStreamManager.GetStream method (3 of 14)

Retrieve a new RecyclableMemoryStream object with no tag and a default initial capacity.

public RecyclableMemoryStream GetStream(Guid id)
parameterdescription
idA unique identifier which can be used to trace usages of the stream.

Return Value

A RecyclableMemoryStream.

See Also


RecyclableMemoryStreamManager.GetStream method (4 of 14)

Retrieve a new RecyclableMemoryStream object with the contents copied from the provided buffer. The provided buffer is not wrapped or used after construction.

public RecyclableMemoryStream GetStream(ReadOnlySpan<byte> buffer)
parameterdescription
bufferThe byte buffer to copy data from.

Return Value

A RecyclableMemoryStream.

Remarks

The new stream's position is set to the beginning of the stream when returned.

See Also


RecyclableMemoryStreamManager.GetStream method (5 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and a default initial capacity.

public RecyclableMemoryStream GetStream(string? tag)
parameterdescription
tagA tag which can be used to track the source of the stream.

Return Value

A RecyclableMemoryStream.

See Also


RecyclableMemoryStreamManager.GetStream method (6 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and a default initial capacity.

public RecyclableMemoryStream GetStream(Guid id, string? tag)
parameterdescription
idA unique identifier which can be used to trace usages of the stream.
tagA tag which can be used to track the source of the stream.

Return Value

A RecyclableMemoryStream.

See Also


RecyclableMemoryStreamManager.GetStream method (7 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and at least the given capacity.

public RecyclableMemoryStream GetStream(string? tag, long requiredSize)
parameterdescription
tagA tag which can be used to track the source of the stream.
requiredSizeThe minimum desired capacity for the stream.

Return Value

A RecyclableMemoryStream.

See Also


RecyclableMemoryStreamManager.GetStream method (8 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and with contents copied from the provided buffer. The provided buffer is not wrapped or used after construction.

public RecyclableMemoryStream GetStream(string? tag, ReadOnlySpan<byte> buffer)
parameterdescription
tagA tag which can be used to track the source of the stream.
bufferThe byte buffer to copy data from.

Return Value

A RecyclableMemoryStream.

Remarks

The new stream's position is set to the beginning of the stream when returned.

See Also


RecyclableMemoryStreamManager.GetStream method (9 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and at least the given capacity.

public RecyclableMemoryStream GetStream(Guid id, string? tag, long requiredSize)
parameterdescription
idA unique identifier which can be used to trace usages of the stream.
tagA tag which can be used to track the source of the stream.
requiredSizeThe minimum desired capacity for the stream.

Return Value

A RecyclableMemoryStream.

See Also


RecyclableMemoryStreamManager.GetStream method (10 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and with contents copied from the provided buffer. The provided buffer is not wrapped or used after construction.

public RecyclableMemoryStream GetStream(Guid id, string? tag, ReadOnlySpan<byte> buffer)
parameterdescription
idA unique identifier which can be used to trace usages of the stream.
tagA tag which can be used to track the source of the stream.
bufferThe byte buffer to copy data from.

Return Value

A RecyclableMemoryStream.

Remarks

The new stream's position is set to the beginning of the stream when returned.

See Also


RecyclableMemoryStreamManager.GetStream method (11 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and at least the given capacity, possibly using a single contiguous underlying buffer.

public RecyclableMemoryStream GetStream(string? tag, long requiredSize, bool asContiguousBuffer)
parameterdescription
tagA tag which can be used to track the source of the stream.
requiredSizeThe minimum desired capacity for the stream.
asContiguousBufferWhether to attempt to use a single contiguous buffer.

Return Value

A RecyclableMemoryStream.

Remarks

Retrieving a RecyclableMemoryStream which provides a single contiguous buffer can be useful in situations where the initial size is known and it is desirable to avoid copying data between the smaller underlying buffers to a single large one. This is most helpful when you know that you will always call GetBuffer on the underlying stream.

See Also


RecyclableMemoryStreamManager.GetStream method (12 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and at least the given capacity, possibly using a single contiguous underlying buffer.

public RecyclableMemoryStream GetStream(Guid id, string? tag, long requiredSize, 
    bool asContiguousBuffer)
parameterdescription
idA unique identifier which can be used to trace usages of the stream.
tagA tag which can be used to track the source of the stream.
requiredSizeThe minimum desired capacity for the stream.
asContiguousBufferWhether to attempt to use a single contiguous buffer.

Return Value

A RecyclableMemoryStream.

Remarks

Retrieving a RecyclableMemoryStream which provides a single contiguous buffer can be useful in situations where the initial size is known and it is desirable to avoid copying data between the smaller underlying buffers to a single large one. This is most helpful when you know that you will always call GetBuffer on the underlying stream.

See Also


RecyclableMemoryStreamManager.GetStream method (13 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and with contents copied from the provided buffer. The provided buffer is not wrapped or used after construction.

public RecyclableMemoryStream GetStream(string? tag, byte[] buffer, int offset, int count)
parameterdescription
tagA tag which can be used to track the source of the stream.
bufferThe byte buffer to copy data from.
offsetThe offset from the start of the buffer to copy from.
countThe number of bytes to copy from the buffer.

Return Value

A RecyclableMemoryStream.

Remarks

The new stream's position is set to the beginning of the stream when returned.

See Also


RecyclableMemoryStreamManager.GetStream method (14 of 14)

Retrieve a new RecyclableMemoryStream object with the given tag and with contents copied from the provided buffer. The provided buffer is not wrapped or used after construction.

public RecyclableMemoryStream GetStream(Guid id, string? tag, byte[] buffer, int offset, int count)
parameterdescription
idA unique identifier which can be used to trace usages of the stream.
tagA tag which can be used to track the source of the stream.
bufferThe byte buffer to copy data from.
offsetThe offset from the start of the buffer to copy from.
countThe number of bytes to copy from the buffer.

Return Value

A RecyclableMemoryStream.

Remarks

The new stream's position is set to the beginning of the stream when returned.

See Also