public static TradeAnswer ReadFromJSON(string answer) { JObject data = JObject.Parse(answer)["return"] as JObject; JValue success = JObject.Parse(answer)["success"] as JValue; JValue error = JObject.Parse(answer)["error"] as JValue; if ((int)success == 1) { var o = data["funds"].ToObject <Dictionary <string, decimal> >(); List <Currency> currencies = new List <Currency>(); foreach (string key in o.Keys) { currencies.Add(new Currency(BTCeCurrencyHelper.FromString(key), o[key])); } TradeAnswer tradeAnwer = new TradeAnswer() { Currencies = currencies, Received = data.Value <decimal>("received"), Remains = data.Value <decimal>("remains"), OrderId = data.Value <int>("order_id") }; return(tradeAnwer); } throw new BTCeAPIException((string)error); }
public static AccountInfo ReadFromJSON(string info) { JObject data = JObject.Parse(info)["return"] as JObject; JValue success = JObject.Parse(info)["success"] as JValue; JValue error = JObject.Parse(info)["error"] as JValue; if ((int)success == 1) { var o = data["funds"].ToObject <Dictionary <string, decimal> >(); List <Currency> currencies = new List <Currency>(); foreach (string key in o.Keys) { currencies.Add(new Currency(BTCeCurrencyHelper.FromString(key), o[key])); } var userInfo = new AccountInfo() { Currencies = currencies, Rights = Rights.ReadFromJSON(data["rights"] as JObject), TransactionsCount = data.Value <int>("transaction_count"), OpenOrders = data.Value <int>("open_orders"), ServerTime = data.Value <int>("server_time") }; return(userInfo); } throw new BTCeAPIException((string)error); }