static string SerializeByBinaryFormatter(SerializableTagCollection serializableTagCollection) { var binaryFormatter = new BinaryFormatter(); using (var memoryStream = new MemoryStream()) { binaryFormatter.Serialize(memoryStream, serializableTagCollection); return(StringByteArrayConverter.ByteArrayToString(memoryStream.GetBuffer())); } }
static SerializableTagCollection DeserializeByBinaryFormatter(string hexadecimalString) { var bytes = StringByteArrayConverter.StringToByteArray(hexadecimalString); var binaryFormatter = new BinaryFormatter(); using (var memoryStream = new MemoryStream(bytes)) { return(( SerializableTagCollection )binaryFormatter.Deserialize(memoryStream)); } }