Class StreamExtensions
IO-related extension methods for
Inheritance
Namespace: X10D.IO
Assembly: X10D.dll
Syntax
public static class StreamExtensions : object
Methods
| Improve this Doc View SourceGetHash<T>(Stream)
Returns the hash of the current stream as an array of bytes using the specified hash algorithm.
Declaration
public static byte[] GetHash<T>(this Stream stream)
where T : HashAlgorithm
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream whose hash is to be computed. |
Returns
Type | Description |
---|---|
System.Byte[] | The hash of |
Type Parameters
Name | Description |
---|---|
T | The type of the |
ReadDecimalBigEndian(Stream)
Reads an
Declaration
public static decimal ReadDecimalBigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Decimal | The big endian value. |
ReadDecimalLittleEndian(Stream)
Reads an
Declaration
public static decimal ReadDecimalLittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Decimal | The big endian value. |
ReadDoubleBigEndian(Stream)
Reads an
Declaration
public static double ReadDoubleBigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Double | The big endian value. |
ReadDoubleLittleEndian(Stream)
Reads an
Declaration
public static double ReadDoubleLittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Double | The little endian value. |
ReadInt16BigEndian(Stream)
Reads an
Declaration
public static short ReadInt16BigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Int16 | The big endian value. |
ReadInt16LittleEndian(Stream)
Reads an
Declaration
public static short ReadInt16LittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Int16 | The little endian value. |
ReadInt32BigEndian(Stream)
Reads an
Declaration
public static int ReadInt32BigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Int32 | The big endian value. |
ReadInt32LittleEndian(Stream)
Reads an
Declaration
public static int ReadInt32LittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Int32 | The little endian value. |
ReadInt64BigEndian(Stream)
Reads an
Declaration
public static long ReadInt64BigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Int64 | The big endian value. |
ReadInt64LittleEndian(Stream)
Reads an
Declaration
public static long ReadInt64LittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Int64 | The little endian value. |
ReadSingleBigEndian(Stream)
Reads an
Declaration
public static float ReadSingleBigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Single | The big endian value. |
ReadSingleLittleEndian(Stream)
Reads an
Declaration
public static float ReadSingleLittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.Single | The little endian value. |
ReadUInt16BigEndian(Stream)
Reads an
Declaration
public static ushort ReadUInt16BigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.UInt16 | The big endian value. |
ReadUInt16LittleEndian(Stream)
Reads an
Declaration
public static ushort ReadUInt16LittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.UInt16 | The little endian value. |
ReadUInt32BigEndian(Stream)
Reads an
Declaration
public static uint ReadUInt32BigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.UInt32 | The big endian value. |
ReadUInt32LittleEndian(Stream)
Reads an
Declaration
public static uint ReadUInt32LittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.UInt32 | The little endian value. |
ReadUInt64BigEndian(Stream)
Reads an
Declaration
public static ulong ReadUInt64BigEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.UInt64 | The big endian value. |
ReadUInt64LittleEndian(Stream)
Reads an
Declaration
public static ulong ReadUInt64LittleEndian(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the value should be read. |
Returns
Type | Description |
---|---|
System.UInt64 | The little endian value. |
TryWriteHash<T>(Stream, Span<Byte>, out Int32)
Returns the hash of the current stream as an array of bytes using the specified hash algorithm.
Declaration
public static bool TryWriteHash<T>(this Stream stream, Span<byte> destination, out int bytesWritten)
where T : HashAlgorithm
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream whose hash is to be computed. |
Span<System.Byte> | destination | When this method returns, contains the computed hash of |
System.Int32 | bytesWritten | When this method returns, the total number of bytes written into destination. This parameter is treated as uninitialized. |
Returns
Type | Description |
---|---|
System.Boolean | true if the destination is long enough to receive the hash; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T | The type of the |
WriteBigEndian(Stream, Decimal)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, decimal value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Decimal | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, Double)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, double value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Double | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, Int16)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, short value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Int16 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, Int32)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, int value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Int32 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, Int64)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, long value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Int64 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, Single)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, float value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Single | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, UInt16)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, ushort value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.UInt16 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, UInt32)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, uint value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.UInt32 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteBigEndian(Stream, UInt64)
Writes a
Declaration
public static int WriteBigEndian(this Stream stream, ulong value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.UInt64 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, Decimal)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, decimal value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Decimal | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, Double)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, double value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Double | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, Int16)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, short value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Int16 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, Int32)
Writes an
Declaration
public static int WriteLittleEndian(this Stream stream, int value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Int32 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, Int64)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, long value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Int64 | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, Single)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, float value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.Single | value | The |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, UInt16)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, ushort value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.UInt16 | value | The two-byte signed integer to write. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, UInt32)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, uint value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.UInt32 | value | The two-byte signed integer to write. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |
WriteLittleEndian(Stream, UInt64)
Writes a
Declaration
public static int WriteLittleEndian(this Stream stream, ulong value)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to which the value should be written. |
System.UInt64 | value | The two-byte signed integer to write. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the stream. |