public override void WriteTo(BinaryWriter writer) { base.WriteTo(writer); writer.Write((ushort)Flags); writer.Write(TransactionPosition); writer.Write(TransactionOffset); if (Version == LogRecordVersion.LogRecordV0) { int expectedVersion = ExpectedVersion == long.MaxValue - 1 ? int.MaxValue - 1 : (int)ExpectedVersion; writer.Write(expectedVersion); } else { writer.Write(ExpectedVersion); } writer.Write(EventStreamId); writer.Write(EventId.ToByteArray()); writer.Write(CorrelationId.ToByteArray()); writer.Write(TimeStamp.Ticks); writer.Write(EventType); writer.Write(Data.Length); writer.Write(Data.Span); writer.Write(Metadata.Length); writer.Write(Metadata.Span); }