Table of Contents

Class DataStreamFactory

Namespace
Yarhl.IO
Assembly
Yarhl.dll

Factory of DataStream.

public static class DataStreamFactory
Inheritance
DataStreamFactory
Inherited Members

Methods

FromArray(byte[])

Creates a new DataStream from an array of data.

public static DataStream FromArray(byte[] data)

Parameters

data byte[]

The array of data to use in the stream.

Returns

DataStream

A new DataStream.

FromArray(byte[], int, int)

Creates a new DataStream from an array of data.

public static DataStream FromArray(byte[] data, int offset, int length)

Parameters

data byte[]

The array of data to use in the stream.

offset int

Offset in the array of data.

length int

Length of the new stream.

Returns

DataStream

A new DataStream.

FromFile(string, FileOpenMode)

Creates a new DataStream from a file.

public static DataStream FromFile(string path, FileOpenMode mode)

Parameters

path string

The path of the file.

mode FileOpenMode

The mode to open the file.

Returns

DataStream

A new DataStream.

FromFile(string, FileOpenMode, long, long)

Creates a new DataStream from a section of a file.

public static DataStream FromFile(string path, FileOpenMode mode, long offset, long length)

Parameters

path string

The path of the file.

mode FileOpenMode

The mode to open the file.

offset long

Offset from the start of the file.

length long

Length of the new stream.

Returns

DataStream

A new DataStream.

FromMemory()

Creates a new DataStream in memory.

public static DataStream FromMemory()

Returns

DataStream

A new DataStream.

FromStream(Stream)

Creates a new DataStream from a Stream.

public static DataStream FromStream(Stream stream)

Parameters

stream Stream

The stream to use as a base.

Returns

DataStream

A new DataStream.

Remarks

The dispose ownership is transferred to the new DataStream.

FromStream(Stream, long, long)

Creates a new DataStream from a section of a Stream.

public static DataStream FromStream(Stream stream, long offset, long length)

Parameters

stream Stream

The stream to use as a base.

offset long

Offset of the base stream.

length long

Length of the new substream.

Returns

DataStream

A new DataStream.

Remarks

The life-management of the stream is transferred to the DataStream. This means that disposing the new DataStream will potentially dispose the underlying stream.

Check FromStreamKeepingOwnership(Stream, long, long) if you don't want this behavior.

FromStreamKeepingOwnership(Stream, long, long)

Creates a new DataStream from a section of a Stream.

public static DataStream FromStreamKeepingOwnership(Stream stream, long offset, long length)

Parameters

stream Stream

The stream to use as a base.

offset long

Offset of the base stream.

length long

Length of the new substream.

Returns

DataStream

A new DataStream.

Remarks

The dispose ownership is not transferred to the new DataStream. Instead, the caller is still responsible to dispose according the stream argument.