Table of Contents

Method Create

Namespace
KZDev.PerfUtils
Assembly
KZDev.PerfUtils.dll

Create()

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized to zero.

public static MemoryStreamSlim Create()

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized to zero.

Create(int)

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized as specified.

public static MemoryStreamSlim Create(int capacity)

Parameters

capacity int

The initial capacity of the stream in bytes.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized as specified.

Create(MemoryStreamSlimOptions)

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized to zero, and options to configure the stream instance.

public static MemoryStreamSlim Create(MemoryStreamSlimOptions options)

Parameters

options MemoryStreamSlimOptions

Options to configure the stream instance.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized to zero.

Create(int, MemoryStreamSlimOptions)

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized as specified, and options to configure the stream instance.

public static MemoryStreamSlim Create(int capacity, MemoryStreamSlimOptions options)

Parameters

capacity int

The initial capacity of the stream in bytes.

options MemoryStreamSlimOptions

Options to configure the stream instance.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized as specified.

Create(Action<MemoryStreamSlimOptions>)

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized to zero, and a delegate to set up options for the stream instance.

public static MemoryStreamSlim Create(Action<MemoryStreamSlimOptions> optionsSetup)

Parameters

optionsSetup Action<MemoryStreamSlimOptions>

Delegate to set up options to configure the stream instance.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized to zero.

Create(int, Action<MemoryStreamSlimOptions>)

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized as specified, and a delegate to set up options for the stream instance.

public static MemoryStreamSlim Create(int capacity, Action<MemoryStreamSlimOptions> optionsSetup)

Parameters

capacity int

The initial capacity of the stream in bytes.

optionsSetup Action<MemoryStreamSlimOptions>

Delegate to set up options to configure the stream instance.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized as specified.

Create<TState>(Action<MemoryStreamSlimOptions, TState>, TState)

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized to zero, and a delegate to set up options for the stream instance.

public static MemoryStreamSlim Create<TState>(Action<MemoryStreamSlimOptions, TState> optionsSetup, TState state)

Parameters

optionsSetup Action<MemoryStreamSlimOptions, TState>

Delegate to set up options to configure the stream instance.

state TState

State data to pass to the options setup delegate.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized to zero.

Type Parameters

TState

The type of the state data to pass to the options setup delegate.

Create<TState>(int, Action<MemoryStreamSlimOptions, TState>, TState)

Creates a new instance of the MemoryStreamSlim class with an expandable capacity initialized as specified, and a delegate to set up options for the stream instance.

public static MemoryStreamSlim Create<TState>(int capacity, Action<MemoryStreamSlimOptions, TState> optionsSetup, TState state)

Parameters

capacity int

The initial capacity of the stream in bytes.

optionsSetup Action<MemoryStreamSlimOptions, TState>

Delegate to set up options to configure the stream instance.

state TState

State data to pass to the options setup delegate.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class with an expandable capacity initialized as specified.

Type Parameters

TState

The type of the state data to pass to the options setup delegate.

Create(byte[])

Creates a new non-resizable instance of the MemoryStreamSlim class based on the specified byte array.

public static MemoryStreamSlim Create(byte[] buffer)

Parameters

buffer byte[]

The array of unsigned bytes from which to create the current stream.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class based on the specified byte array.

Remarks

This will return a Fixed model MemoryStreamSlim instance that simply wraps a standard MemoryStream instance around the provided buffer, and will not use any of the specialized memory management features of the Dynamic mode instances. In general, this should only be used to provide a consistent environment for code that expects a MemoryStreamSlim instance, or to allow the metric counters and logging available with MemoryStreamSlim, otherwise, there is no specific benefit to using this over a standard MemoryStream instance.

Create(byte[], bool)

Creates a new non-resizable instance of the MemoryStreamSlim class based on the specified byte array with the CanWrite property set as specified.

public static MemoryStreamSlim Create(byte[] buffer, bool writable)

Parameters

buffer byte[]

The array of unsigned bytes from which to create the current stream.

writable bool

The setting of the CanWrite property, which determines whether the stream supports writing.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class based on the specified byte array with the CanWrite property set as specified.

Remarks

This will return a Fixed model MemoryStreamSlim instance that simply wraps a standard MemoryStream instance around the provided buffer, and will not use any of the specialized memory management features of the Dynamic mode instances. In general, this should only be used to provide a consistent environment for code that expects a MemoryStreamSlim instance, or to allow the metric counters and logging available with MemoryStreamSlim, otherwise, there is no specific benefit to using this over a standard MemoryStream instance.

Create(byte[], int, int)

Creates a new non-resizable instance of the MemoryStreamSlim class based on the specified region (index) of a byte array.

public static MemoryStreamSlim Create(byte[] buffer, int index, int count)

Parameters

buffer byte[]

The array of unsigned bytes from which to create the current stream.

index int

The index in buffer at which the stream begins.

count int

The length of the stream in bytes.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class based on the specified region (index) of a byte array.

Remarks

This will return a Fixed model MemoryStreamSlim instance that simply wraps a standard MemoryStream instance around the provided buffer, and will not use any of the specialized memory management features of the Dynamic mode instances. In general, this should only be used to provide a consistent environment for code that expects a MemoryStreamSlim instance, or to allow the metric counters and logging available with MemoryStreamSlim, otherwise, there is no specific benefit to using this over a standard MemoryStream instance.

Exceptions

ArgumentOutOfRangeException

The index or count is outside the bounds of the buffer.

Create(byte[], int, int, bool)

Creates a new non-resizable instance of the MemoryStreamSlim class based on the specified region of a byte array, with the CanWrite property set as specified.

public static MemoryStreamSlim Create(byte[] buffer, int index, int count, bool writable)

Parameters

buffer byte[]

The array of unsigned bytes from which to create the current stream.

index int

The index in buffer at which the stream begins.

count int

The length of the stream in bytes.

writable bool

The setting of the CanWrite property, which determines whether the stream supports writing.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class based on the specified region of a byte array, with the CanWrite property set as specified.

Remarks

This will return a Fixed model MemoryStreamSlim instance that simply wraps a standard MemoryStream instance around the provided buffer, and will not use any of the specialized memory management features of the Dynamic mode instances. In general, this should only be used to provide a consistent environment for code that expects a MemoryStreamSlim instance, or to allow the metric counters and logging available with MemoryStreamSlim, otherwise, there is no specific benefit to using this over a standard MemoryStream instance.

Exceptions

ArgumentOutOfRangeException

The index or count is outside the bounds of the buffer.

Create(byte[], int, int, bool, bool)

Creates a new non-resizable instance of the MemoryStreamSlim class based on the specified region of a byte array, with the CanWrite property set as specified, and the ability to call GetBuffer() set as specified.

public static MemoryStreamSlim Create(byte[] buffer, int index, int count, bool writable, bool publiclyVisible)

Parameters

buffer byte[]

The array of unsigned bytes from which to create the current stream.

index int

The index in buffer at which the stream begins.

count int

The length of the stream in bytes.

writable bool

The setting of the CanWrite property, which determines whether the stream supports writing.

publiclyVisible bool

true to enable GetBuffer(), which returns the unsigned byte array from which the stream was created; otherwise, false.

Returns

MemoryStreamSlim

An instance of the MemoryStreamSlim class based on the specified region of a byte array, with the CanWrite property set as specified, and the ability to call GetBuffer() set as specified.

Remarks

This will return a Fixed model MemoryStreamSlim instance that simply wraps a standard MemoryStream instance around the provided buffer, and will not use any of the specialized memory management features of the Dynamic mode instances. In general, this should only be used to provide a consistent environment for code that expects a MemoryStreamSlim instance, or to allow the metric counters and logging available with MemoryStreamSlim, otherwise, there is no specific benefit to using this over a standard MemoryStream instance.

Exceptions

ArgumentOutOfRangeException

The index or count is outside the bounds of the buffer.