public Depth(dynamic jsonObj) { string[] orderTypes = { "asks", "bids" }; List<Order> orders = new List<Order>(); foreach (string orderType in orderTypes) { JToken tokens = null; if (jsonObj.data.TryGetValue(orderType, out tokens)) { foreach (JToken token in (JArray)tokens) { Order order = new Order(token, orderType); orders.Add(order); } } } this.orders = orders; }
public Orders(dynamic jsonObj) { this.orders = new List<Order>(); JToken data = null; jsonObj.TryGetValue("data", out data); foreach (JToken token in data) { Order order = new Order(); order.oid = Guid.Parse(token["oid"].Value<String>()); order.currency = getCurrency(token["currency"].Value<String>()); order.item = getItem(token["item"].Value<String>()); order.amount = new Amount() { value = token["amount"].Value<Decimal>("value"), value_int = token["amount"].Value<Int64>("value_int"), display = token["amount"].Value<String>("display"), display_short = token["amount"].Value<String>("display_short"), currency = getCurrency(token["amount"].Value<String>("currency")) }; order.effective_amount = new Amount() { value = token["effective_amount"].Value<Decimal>("value"), value_int = token["effective_amount"].Value<Int64>("value_int"), display = token["effective_amount"].Value<String>("display"), display_short = token["effective_amount"].Value<String>("display_short"), currency = getCurrency(token["effective_amount"].Value<String>("currency")) }; order.price = new Price() { value = token["price"].Value<Decimal>("value"), value_int = token["price"].Value<Int64>("value_int"), display = token["price"].Value<String>("display"), display_short = token["price"].Value<String>("display_short"), currency = getCurrency(token["price"].Value<String>("currency")) }; order.date = UnixTimeStampToDate(token["date"].Value<Double>()); order.status = getStatus(token["status"].Value<String>()); order.priority = token["priority"].Value<Int64>(); order.type = Order.getOrderType(token["type"].Value<String>()); orders.Add(order); } }