Beispiel #1
0
        public static OrderTrigger Deserialize(byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

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

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

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

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

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

            var orderTrigger = new OrderTrigger();

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

            return(orderTrigger);
        }
Beispiel #2
0
        public static byte[] Serialize(OrderTrigger orderTrigger)
        {
            if (orderTrigger == null)
            {
                throw new ArgumentNullException(nameof(orderTrigger));
            }

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