Table of Contents

Class StreamExtensions

Namespace
Root.ReportNet.Pdf.Tools
Assembly
ReportNet.dll

Provides extension methods for working with streams.

public static class StreamExtensions
Inheritance
StreamExtensions
Inherited Members

Methods

ReadFixed(Stream)

Reads a fixed-point number from the stream.

public static float ReadFixed(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

float

The read fixed-point number.

Exceptions

NullReferenceException

The stream is null.

ReportException

Invalid negative value.

ReportException

An invalid value for decimals is encountered.

ReadInt16M(Stream)

Reads a short (Int16) value in big-endian (MSB) format from the stream.

public static short ReadInt16M(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

short

The read short value.

Exceptions

NullReferenceException

The stream is null.

InvalidDataException

The end of the stream is reached unexpectedly.

ReadInt16MN(Stream)

Reads a nullable short (Int16) value in big-endian (MSB) format from the stream.

public static short? ReadInt16MN(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

short?

The read short value or null if the end of the stream is reached before reading the required number of bytes.

Exceptions

NullReferenceException

The stream is null.

ReadInt32M(Stream)

Reads an int (Int32) value in big-endian (MSB) format from the stream.

public static int ReadInt32M(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

int

The read int value.

Exceptions

NullReferenceException

The stream is null.

InvalidDataException

The end of the stream is reached unexpectedly.

ReadInt32MN(Stream)

Reads a nullable int (Int32) value in big-endian (MSB) format from the stream.

public static int? ReadInt32MN(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

int?

The read int value or null if the end of the stream is reached before reading the required number of bytes.

Exceptions

NullReferenceException

The stream is null.

ReadInt64M(Stream)

Reads a long (Int64) value in big-endian (MSB) format from the stream.

public static long ReadInt64M(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

long

The read long value.

Exceptions

NullReferenceException

The stream is null.

InvalidDataException

The end of the stream is reached unexpectedly.

ReadInt64MN(Stream)

Reads a nullable long (Int64) value in big-endian (MSB) format from the stream.

public static long? ReadInt64MN(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

long?

The read long value or null if the end of the stream is reached before reading the required number of bytes.

Exceptions

NullReferenceException

The stream is null.

ReadString(Stream, int)

Reads a string of the specified length from the stream.

public static string? ReadString(this Stream stream, int length)

Parameters

stream Stream

The stream to read from.

length int

The length of the string to read.

Returns

string

The read string or null if the end of the stream is reached before reading the specified number of bytes.

Exceptions

NullReferenceException

The stream is null.

ArgumentOutOfRangeException

The length is less than or equal to 0.

ReadStringUTF8(Stream, int)

Reads a UTF-8 encoded string of the specified length from the stream.

public static string? ReadStringUTF8(this Stream stream, int length)

Parameters

stream Stream

The stream to read from.

length int

The length of the string to read.

Returns

string

The read string or null if the end of the stream is reached before reading the specified number of bytes.

Exceptions

NullReferenceException

The stream is null.

ArgumentOutOfRangeException

The length is less than or equal to 0.

ReadStringUnicode(Stream, int)

Reads an Unicode encoded string of the specified length from the stream.

public static string? ReadStringUnicode(this Stream stream, int length)

Parameters

stream Stream

The stream to read from.

length int

The length of the string to read.

Returns

string

The read string or null if the end of the stream is reached before reading the specified number of bytes.

Exceptions

NullReferenceException

The stream is null.

ArgumentOutOfRangeException

The length is less than or equal to 0.

ReadUint16M(Stream)

Reads an ushort (UInt16) value in big-endian (MSB) format from the stream.

public static ushort ReadUint16M(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

ushort

The read ushort value.

Exceptions

NullReferenceException

The stream is null.

InvalidDataException

The end of the stream is reached unexpectedly.

ReadUint16MN(Stream)

Reads a nullable ushort (UInt16) value in big-endian (MSB) format from the stream.

public static ushort? ReadUint16MN(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

ushort?

The read ushort value or null if the end of the stream is reached before reading the required number of bytes.

Exceptions

NullReferenceException

The stream is null.

ReadUint32M(Stream)

Reads a uint (UInt32) value in big-endian (MSB) format from the stream.

public static uint ReadUint32M(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

uint

The read uint value.

Exceptions

NullReferenceException

The stream is null.

InvalidDataException

The end of the stream is reached unexpectedly.

ReadUint32MN(Stream)

Reads a nullable uint (UInt32) value in big-endian (MSB) format from the stream.

public static uint? ReadUint32MN(this Stream stream)

Parameters

stream Stream

The stream to read from.

Returns

uint?

The read uint value or null if the end of the stream is reached before reading the required number of bytes.

Exceptions

NullReferenceException

The stream is null.

WriteInt32M(Stream, int)

Writes an int (Int32) value in big-endian (MSB) format to the stream.

public static void WriteInt32M(this Stream stream, int value)

Parameters

stream Stream

The stream to write to.

value int

The int value to write.

Exceptions

NullReferenceException

The stream is null.

WriteLine(Stream, string?)

Writes the specified string followed by a new line character (\n) to the stream. If the text is null, only the new line character is written.

public static void WriteLine(this Stream stream, string? text = null)

Parameters

stream Stream

The stream to write to.

text string

The string to write.

Exceptions

NullReferenceException

The stream is null.

WriteString(Stream, string)

Writes the specified string to the stream.

public static void WriteString(this Stream stream, string text)

Parameters

stream Stream

The stream to write to.

text string

The string to write.

Exceptions

NullReferenceException

The stream is null.

ArgumentNullException

The text is null.