using System; using System.IO; namespace Asb.Base.V2.Serialization; public static class SerializationExtensions { public static void WriteStringSafe(this BinaryWriter writer, string value) { if (writer == null) { throw new ArgumentNullException("writer"); } writer.Write(value == null); if (value != null) { writer.Write(value); } } public static string ReadStringSafe(this BinaryReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } if (!reader.ReadBoolean()) { return reader.ReadString(); } return null; } }