static byte[] GetRawWoplBytes(WoplFile wopl) { using var ms = new MemoryStream(); using var bw = new BinaryWriter(ms); WoplFile.Serdes(wopl, new GenericBinaryWriter(bw, Encoding.ASCII.GetBytes, ApiUtil.Assert)); return(ms.ToArray()); }
static void WriteWopl(WoplFile wopl, string filename) { using var ms = new MemoryStream(); using var bw = new BinaryWriter(ms); WoplFile.Serdes(wopl, new GenericBinaryWriter(bw, Encoding.ASCII.GetBytes, Console.WriteLine)); byte[] bytes = ms.ToArray(); File.WriteAllBytes(filename, bytes); }
static WoplFile ReadWopl(string filename) { using var stream2 = File.OpenRead(filename); using var br = new BinaryReader(stream2); return(WoplFile.Serdes(null, new GenericBinaryReader(br, br.BaseStream.Length, Encoding.ASCII.GetString, Console.WriteLine))); }