Ejemplo n.º 1
0
        public static OrderAccept Deserialize(byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            if (bytes.Length != sizeOfMessage)
            {
                throw new Exception("Order accept message must be of Size : " + sizeOfMessage);
            }

            var messageType = (MessageType)(bytes[messageTypeOffset]);

            if (messageType != MessageType.OrderAccept)
            {
                throw new Exception("Invalid Message");
            }

            var version = BitConverter.ToInt16(bytes, versionOffset);

            if (version != OrderAcceptSerializer.version)
            {
                throw new Exception("version mismatch");
            }

            var orderAccept = new OrderAccept();

            orderAccept.OrderId   = BitConverter.ToInt32(bytes, orderIdOffset);
            orderAccept.Timestamp = BitConverter.ToInt32(bytes, timestampOffset);

            return(orderAccept);
        }
Ejemplo n.º 2
0
        public static byte[] Serialize(OrderAccept orderAccept)
        {
            if (orderAccept == null)
            {
                throw new ArgumentNullException(nameof(orderAccept));
            }

            return(Serialize(orderAccept.OrderId, orderAccept.Timestamp));
        }