public IMessageIn Visit(OrderReceived msg) { msg.OrderId = (string)_data["order_id"]; msg.Size = (decimal?)_data["size"]; msg.Price = (decimal?)_data["price"]; msg.Funds = (decimal?)_data["funds"]; msg.OrderType = ParseOrderType((string)_data["order_type"]); msg.ClientOrderId = (string)_data["client_oid"]; return(msg); }
public static IMessageIn Parse(string serialized) { var data = Json.ParseObject(serialized); Condition.Requires(data, "data").IsNotNull(); string type = (string)data["type"]; Condition.Requires(type, "type").IsNotNull(); IMessageIn res = null; switch (type) { case "received": res = new OrderReceived(); break; case "open": res = new OrderOpen(); break; case "done": res = new OrderDone(); break; case "match": res = new OrderMatch(); break; case "change": res = new OrderChange(); break; default: throw new ArgumentException("Unexpected message type: " + type); } var parser = new MessageParser(data); parser.ParseCommon(res); return(res.Visit(parser)); }
public object Visit(WebSocket.OrderReceived msg) { return(null); }