public void WriteTo(BinaryWriter writer) { FileValidation.WriteTo(writer, Metadata); if (Data != null) { writer.Write((uint)Data.LongLength); if (Data.Length > 0) { writer.Write(Data); } } else { writer.Write(0U); } }
private byte[] WritePatches(Patch patch) { using (var ms = new MemoryStream()) using (var writer = new BinaryWriter(ms)) { FileValidation.WriteTo(writer, patch.Item1); var patchInfos = patch.Item2; if (patchInfos != null) { writer.Write(patchInfos.Length); foreach (var patchInfo in patchInfos) { patchInfo.WriteTo(writer); } } else { writer.Write(0); } return(ms.ToArray()); } }