<PackageReference Include="System.Drawing.Common" Version="9.0.1" />

BinaryFormatWriter

static class BinaryFormatWriter
Writer that writes specific types in binary format without using the BinaryFormatter.
public static bool TryWrite<T>(Action<Stream, T> action, Stream stream, T value)

Simple wrapper to ensure the stream is reset to it's original position if the action throws.

public static bool TryWrite<T>(Func<Stream, T, bool> func, Stream stream, T value)

Simple wrapper to ensure the stream is reset to it's original position if the func throws or returns false.

public static bool TryWriteArray(Stream stream, Array array)

Writes the given array in binary format if supported.

public static bool TryWriteArrayList(Stream stream, ArrayList list)

Writes the given list in binary format if supported.

public static bool TryWriteFrameworkObject(Stream stream, object value)

Writes the given value if supported.

public static bool TryWriteHashtable(Stream stream, Hashtable hashtable)

Tries to write the given hashtable if supported.

public static bool TryWritePrimitive(Stream stream, object primitive)

Attempts to write a PrimitiveType value in binary format.

public static bool TryWritePrimitiveList(Stream stream, IList list)

Writes the given list in binary format if supported.

public static void WriteDateTime(Stream stream, DateTime value)

Writes a DateTime in binary format.

public static void WriteDecimal(Stream stream, decimal value)

Writes a decimal in binary format.

public static void WriteNativeInt(Stream stream, IntPtr value)

Writes a nint in binary format.

public static void WriteNativeUInt(Stream stream, UIntPtr value)

Writes a nuint in binary format.

public static void WriteNotSupportedException(Stream stream, NotSupportedException exception)

Writes a NotSupportedException in binary format.

public static void WritePointF(Stream stream, PointF value)

Writes a PointF in binary format.

public static void WritePrimitive(Stream stream, object primitive)

Writes a .NET primitive value in binary format.

public static void WritePrimitiveHashtable(Stream stream, Hashtable hashtable)

Writes a Hashtable of primitive to primitive values to the given stream in binary format.

Writes a primitive list in binary format.

public static void WriteRectangleF(Stream stream, RectangleF value)

Writes a RectangleF in binary format.

public static void WriteString(Stream stream, string value)

Writes a string in binary format.

public static void WriteStringList(Stream stream, List<string> list)

Writes a List<T> in binary format.

public static void WriteTimeSpan(Stream stream, TimeSpan value)

Writes a TimeSpan in binary format.