public static byte[] ToBytes(this ShapeContent content, RecyclableMemoryStreamManager manager, Encoding encoding) { using (var output = manager.GetStream()) using (var writer = new BinaryWriter(output, encoding)) { content.Write(writer); writer.Flush(); return(output.ToArray()); } }
public static ShapeContent FromBytes(byte[] data, RecyclableMemoryStreamManager manager, Encoding encoding) { using (var input = manager.GetStream(Guid.NewGuid(), nameof(ZipArchiveWriters), data, 0, data.Length)) using (var reader = new BinaryReader(input, encoding)) return(ShapeContent.Read(reader)); }