Пример #1
0
 public static byte[] Serialize(ulong orderId, OrderMatchingResult result, long timeStamp)
 {
     byte[] msg = new byte[sizeOfMessage];
     Write(msg, messageLengthOffset, sizeOfMessage);
     msg[messageTypeOffset] = (byte)MessageType.OrderMatchingResult;
     Write(msg, versionOffset, version);
     Write(msg, orderIdOffset, orderId);
     Write(msg, resultOffset, (byte)result);
     Write(msg, timestampOffset, timeStamp);
     return(msg);
 }
Пример #2
0
        public static void Serialize(ulong orderId, OrderMatchingResult result, long timeStamp, Span <byte> bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            if (bytes.Length < sizeOfMessage)
            {
                throw new ArgumentException(Constant.INVALID_SIZE, nameof(bytes));
            }

            Write(bytes.Slice(messageLengthOffset), sizeOfMessage);
            bytes[messageTypeOffset] = (byte)MessageType.OrderMatchingResult;
            Write(bytes.Slice(versionOffset), version);
            Write(bytes.Slice(orderIdOffset), orderId);
            Write(bytes.Slice(resultOffset), (byte)result);
            Write(bytes.Slice(timestampOffset), timeStamp);
        }