Class DataStreamFactory
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
intOffset in the array of data.
length
intLength 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
stringThe path of the file.
mode
FileOpenModeThe 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
stringThe path of the file.
mode
FileOpenModeThe mode to open the file.
offset
longOffset from the start of the file.
length
longLength 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
StreamThe 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
StreamThe stream to use as a base.
offset
longOffset of the base stream.
length
longLength 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
StreamThe stream to use as a base.
offset
longOffset of the base stream.
length
longLength 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.