Newtonsoft.Json.JsonConvert.DeserializeObject(string)

Here are the examples of the csharp api Newtonsoft.Json.JsonConvert.DeserializeObject(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2621 Examples 7

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public BitfinexDepositResponse Deposit(string currency, string method, string wallet)
		{
			var depositPost = new BitfinexDepositPost
			{
				Request = DepositRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture),
				Currency = currency,
				Method = method,
				WalletName = wallet
			};

			// var client = GetRestClient(depositPost.Request);
			var response = GetRestResponse(depositPost);

			var depositResponseObj = JsonConvert.DeserializeObject<BitfinexDepositResponse>(response);
			Log.Info("Attempting to deposit: {0} with method: {1} to wallet: {2}", currency, method, wallet);
			Log.Info("Response from exchange: {0}", depositResponseObj);
			return depositResponseObj;
		}

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static IList<BitfinexSymbolStatsResponse> GetPairStats(BtcInfo.PairTypeEnum pairType, BtcInfo.BitfinexUnauthenicatedCallsEnum callType)
		{
			var call = Enum.GetName(typeof(BtcInfo.BitfinexUnauthenicatedCallsEnum), callType);
			var symbol = Enum.GetName(typeof(BtcInfo.PairTypeEnum), pairType);
			var url = @"/v1/" + call.ToLower(CultureInfo.InvariantCulture) + "/" + symbol.ToLower(CultureInfo.InvariantCulture);
			var response = WebApi.GetBaseResponse(url);

			var symbolStatsResponseObj = JsonConvert.DeserializeObject<IList<BitfinexSymbolStatsResponse>>(response);

			foreach (var symbolStatsResponse in symbolStatsResponseObj)
				Log.Info("Pair Stats: {0}", symbolStatsResponse);

			return symbolStatsResponseObj;
		}

19 View Source File : FrmStartPage.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public void RefreshContents()
        {
            Logger.Log("Refreshing");
            lstManga.Items.Clear();
            lstHentai.Items.Clear();
            mangas.Clear();
            DirectoryInfo root = new DirectoryInfo(homeFolder);
            DirectoryInfo[] dirs = root.GetDirectories("*", SearchOption.TopDirectoryOnly);

            foreach (DirectoryInfo dir in dirs)
            {
                // Logger.Log("Refreshing data for directory '" + dir.Name + "'");
                if (dir.Name == "update")
                    continue;
                else if (!dir.Name.StartsWith("h"))
                {
                    var json = File.ReadAllText(dir.FullName + "\\manga.json");
                    var tracker = File.ReadAllText(dir.FullName + "\\tracker");
                    string[] trackerData = tracker.Split('|');
                    // Deserialize the JSON file
                    dynamic contents = JsonConvert.DeserializeObject(json);
                    string mangaName = contents.manga.replacedle;
                    Manga m = new Manga(mangaName, dir, trackerData[0], trackerData[1]);
                    m.LoadSettings();
                    if (m.settings.name == "" || m.settings.name == null)
                    {
                        m.SaveSettings(m.settings.lang, m.settings.group, mangaName);
                        m.LoadSettings();
                    }

                    mangas.Add(m);
                    string name = m.settings.name;
                    if (name.Length > 21)
                    {
                        name = name.Substring(0, 21);
                    }
                    else
                    {
                        name = name.PadRight(21);
                    }
                    lstManga.Items.Add(name + "  »  c" + trackerData[0] + ",p" + trackerData[1]);
                }
                else // Hentai
                {
                    string replacedle = File.ReadAllText(dir.FullName + "\\replacedle");
                    var tracker = File.ReadAllText(dir.FullName + "\\tracker");
                    string[] trackerData = tracker.Split('|');

                    Manga m = new Manga(replacedle, dir, trackerData[0], trackerData[1]);
                    mangas.Add(m);
                    string name = m.name;
                    if (name.Length > 21)
                    {
                        name = name.Substring(0, 21);
                    }
                    else
                    {
                        name = name.PadRight(21);
                    }
                    lstHentai.Items.Add(name + "  »  p" + trackerData[1]);
                }
            }
            if (lstManga.Items.Count > 0)
            {
                lstManga.SelectedIndex = 0;
            }
            if (lstHentai.Items.Count > 0)
            {
                lstHentai.SelectedIndex = 0;
            }
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public IList<BitfinexHistoryResponse> GetHistory(string currency, string since, string until, int limit, string wallet)
		{
			var historyPost = new BitfinexHistoryPost
			{
				Request = HistoryRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture),
				Currency = currency,
				Since = since,
				Until = until,
				Limit = limit,
				Wallet = wallet
			};

			var response = GetRestResponse(historyPost);
			var historyResponseObj = JsonConvert.DeserializeObject<IList<BitfinexHistoryResponse>>(response);

			Log.Info("History:");
			foreach (var history in historyResponseObj)
				Log.Info("{0}", history);

			return historyResponseObj;
		}

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static BitfinexPublicTickerGet GetPublicTicker(BtcInfo.PairTypeEnum pairType, BtcInfo.BitfinexUnauthenicatedCallsEnum callType)
		{
			var call = Enum.GetName(typeof(BtcInfo.BitfinexUnauthenicatedCallsEnum), callType);
			var symbol = Enum.GetName(typeof(BtcInfo.PairTypeEnum), pairType);
			var url = @"/v1/" + call.ToLower(CultureInfo.InvariantCulture) + "/" + symbol.ToLower(CultureInfo.InvariantCulture);
			var response = WebApi.GetBaseResponse(url);

			var publicticketResponseObj = JsonConvert.DeserializeObject<BitfinexPublicTickerGet>(response);
			Log.Info("Ticker: {0}", publicticketResponseObj);

			return publicticketResponseObj;
		}

19 View Source File : Nhentai.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public override void _Load()
        {
            string input = File.ReadAllText(FileHelper.GetFilePath(hentaiRoot, "manga.json"));
            MangaInfo info = JsonConvert.DeserializeObject<MangaInfo>(input);

            id = info.Id;
            name = info.Name;
            userreplacedle = info.UserName;
            currentpage = info.Page;

            _PopulateChapters();
        }

19 View Source File : BitstampApi.cs
License : MIT License
Project Creator : aabiryukov

public static List<Transaction> GetTransactions()
        {
			const string queryStr = "https://www.bitstamp.net/api/transactions/";
			var json = WebApi.Query(queryStr);
	        var list = JsonConvert.DeserializeObject<List<Transaction>>(json);
	        return list;
        }

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : 3RD-Dimension

private void AutoUpdaterOnParseUpdateInfoEvent(ParseUpdateInfoEventArgs args)
        {
            dynamic json = JsonConvert.DeserializeObject(args.RemoteData);

            string VersionGitHub = json.tag_name; // Version Number - Change this to tag_name on deployment

            string replacedetDownloadURL = "";
            VersionGitHub = (VersionGitHub.Remove(0, 1)); // Remove "v" from beginning
            Version v = new Version(VersionGitHub); // Conver to Version

            foreach (var replacedets in json.replacedets)
            {
                replacedetDownloadURL = replacedets.browser_download_url;
            }

            args.UpdateInfo = new UpdateInfoEventArgs
            {
                CurrentVersion = v,
                ChangelogURL = json.body,
                //Mandatory = json.mandatory,
                DownloadURL = replacedetDownloadURL
            };
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public IList<BitfinexActiveCreditsResponse> GetActiveCredits()
		{
			var activeCreditsPost = new BitfinexPostBase
			{
				Request = ActiveCreditsRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture)
			};

			var response = GetRestResponse(activeCreditsPost);
			var activeCreditsResponseObj = JsonConvert.DeserializeObject<IList<BitfinexActiveCreditsResponse>>(response);

			Log.Info("Active Credits:");
			foreach (var activeCredits in activeCreditsResponseObj)
				Log.Info("Credits: {0}", activeCredits.ToString());

			return activeCreditsResponseObj;
		}

19 View Source File : FrmStartPage.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public void AddManga(string api, string num, bool isUpdate)
        {
            string json;
            if (api != null)
            {
                using (var wc = new System.Net.WebClient())
                {
                    json = wc.DownloadString(api);
                }
            }
            else
            {
                json = File.ReadAllText(homeFolder + "\\" + num + "\\manga.json");
            }

            // Deserialize the JSON file
            dynamic contents = JsonConvert.DeserializeObject(json);
            string mangaName = contents.manga.replacedle;
            string mangaDirectory = homeFolder + "\\" + num;

            if (!Directory.Exists(mangaDirectory))
            {
                Logger.Log("Creating directory '" + mangaDirectory + "' and related files");
                Directory.CreateDirectory(mangaDirectory);
                File.WriteAllText(mangaDirectory + "\\manga.json", json); // Write the JSON to a file
                File.WriteAllText(mangaDirectory + "\\tracker", "1|1"); // Write initial tracking info to a file
            }
            File.WriteAllText(mangaDirectory + "\\downloading", ""); // Create "Downloading" file

            Manga m = new Manga(mangaName, new DirectoryInfo(mangaDirectory), "1", "1");

            if (!isUpdate)
            {
                DialogResult result = new FrmMangaSettings(m).ShowDialog();
                MessageBox.Show("Downloading data...\nYou may close the Browser as you desire.");
            }
            m.LoadSettings();
            downloadManager.AddMDToQueue(m, contents.chapter, isUpdate);
            RefreshContents();
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public BitfinexCancelReplaceOrderResponse CancelReplaceOrder(BitfinexCancelReplacePost replaceOrder)
		{
			replaceOrder.Request = OrderCancelRequestUrl + CancelReplaceRequestUrl;
			replaceOrder.Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture);

			var response = GetRestResponse(replaceOrder);

			var replaceOrderResponseObj = JsonConvert.DeserializeObject<BitfinexCancelReplaceOrderResponse>(response);
			replaceOrderResponseObj.OriginalOrderId = replaceOrder.CancelOrderId;

			Log.Info("Cancel Replace: {0}");
			Log.Info("Response From Exchange: {0}", replaceOrderResponseObj.ToString());

			return replaceOrderResponseObj;
		}

19 View Source File : BitstampApi.cs
License : MIT License
Project Creator : aabiryukov

public static T DeserializeBitstampObject<T>(string json)
		{
			CheckBitstampError(json);
			var obj = JsonConvert.DeserializeObject<T>(json);
			return obj;
		}

19 View Source File : KissManga.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public override void _Load(bool doChapters)
        {
            string input = File.ReadAllText(FileHelper.GetFilePath(mangaRoot, "manga.json"));
            MangaInfo info = JsonConvert.DeserializeObject<MangaInfo>(input);

            id = info.Id;
            name = info.Name;
            userlang = info.LangCode;
            usergroup = info.Group;
            userreplacedle = info.UserName;
            currentchapter = info.Chapter;
            currentpage = info.Page;
            lastchapter = info.Latest;

            if (doChapters)
                _PopulateChapters();
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public BitfinexOrderStatusResponse GetOrderStatus(int orderId)
		{
			var orderStatusPost = new BitfinexOrderStatusPost
			{
				Request = OrderStatusRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture),
				OrderId = orderId
			};

			var response = GetRestResponse(orderStatusPost);
			var orderStatusResponseObj = JsonConvert.DeserializeObject<BitfinexOrderStatusResponse>(response);

			Log.Info("OrderId: {0} Status: {1}", orderId, orderStatusResponseObj);

			return orderStatusResponseObj;
		}

19 View Source File : ImClient.cs
License : MIT License
Project Creator : 2881099

public void EventBus(
        Action<(Guid clientId, string clientMetaData)> online,
        Action<(Guid clientId, string clientMetaData)> offline)
    {
        var chanOnline = $"evt_{_redisPrefix}Online";
        var chanOffline = $"evt_{_redisPrefix}Offline";
        _redis.Subscribe(new[] { chanOnline, chanOffline }, (chan, msg) =>
        {
            if (chan == chanOnline) online(JsonConvert.DeserializeObject<(Guid clientId, string clientMetaData)>(msg as string));
            if (chan == chanOffline) offline(JsonConvert.DeserializeObject<(Guid clientId, string clientMetaData)>(msg as string));
        });
    }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public IList<BitfinexMarginPositionResponse> GetActivePositions()
		{
			var activePositionsPost = new BitfinexPostBase
			{
				Request = ActivePositionsRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture)
			};

			var response = GetRestResponse(activePositionsPost);

			var activePositionsResponseObj = JsonConvert.DeserializeObject<IList<BitfinexMarginPositionResponse>>(response);

			Log.Info("Active Positions: ");
			foreach (var activePos in activePositionsResponseObj)
				Log.Info("Position: {0}", activePos);

			return activePositionsResponseObj;
		}

19 View Source File : Updater.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public static void Start()
        {
            WFClient.logger.Log("Checking for updates");

            string json;
            using (var wc = new System.Net.WebClient())
            {
                json = wc.DownloadString("https://raw.githubusercontent.com/ninevult/MikuReader/master/MikuReader-WF/updater/wfupdate.json");
            }
            UpdateInfo info = JsonConvert.DeserializeObject<UpdateInfo>(json);

            if (float.Parse(info.Update_major) > float.Parse(WFClient.CLIENT_MAJOR)
                || float.Parse(info.Update_minor) > float.Parse(WFClient.CLIENT_MINOR))
            {
                new FrmUpdate(info).ShowDialog();
            }

            // AutoUpdater.Start("https://raw.githubusercontent.com/ninevult/MikuReader/master/MikuReader-WF/updater/wfupdate.xml");
            // AutoUpdater.RunUpdateAsAdmin = true;
            // AutoUpdater.OpenDownloadPage = true;
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public static List<TradeHistory> GetTradeHistory(int limit)
		{
			var queryStr = string.Format(CultureInfo.InvariantCulture, "https://" + apiHost + "/data/historydata?limit={0}", limit);
			var json = WebApi.Query(queryStr);
			var list = JsonConvert.DeserializeObject<List<TradeHistory>>(json);
			return list;
		}

19 View Source File : ConditionTaskForm.cs
License : Apache License 2.0
Project Creator : 214175590

public void init()
        {
            ThreadPool.QueueUserWorkItem((a) =>
            {
                this.BeginInvoke((MethodInvoker)delegate()
                {
                    string json = YSTools.YSFile.readFileToString(MainForm.CONF_DIR + "shell_temp.json");
                    JObject obj = JsonConvert.DeserializeObject<JObject>(json);

                    conditionTemp = (JObject)obj["condition_temp"];                    

                    JObject shellTemp = (JObject)obj["task_shell_temp"][typeArr[index]];
                    if (null != shellTemp)
                    {
                        ListViewItem item = null;
                        ListViewItem.ListViewSubItem subItem = null;
                        foreach (var o in shellTemp)
                        {
                            item = new ListViewItem();
                            item.Tag = o;
                            item.Text = o.Key;

                            subItem = new ListViewItem.ListViewSubItem();
                            subItem.Text = o.Value.ToString();

                            item.SubItems.Add(subItem);
                            scb_template.Items.Add(item);
                        }
                    }

                    JArray varsTemp = (JArray)obj["vars_temp"][typeArr[index]];
                    if (null != varsTemp)
                    {
                        ListViewItem item = null;
                        ListViewItem.ListViewSubItem subItem = null;
                        foreach (var o in varsTemp)
                        {
                            item = new ListViewItem();
                            item.Tag = o;
                            item.Text = o["value"].ToString();

                            subItem = new ListViewItem.ListViewSubItem();
                            subItem.Text = o["desc"].ToString();

                            item.SubItems.Add(subItem);
                            var_list.Items.Add(item);
                        }
                    }

                });
            });
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public IList<BitfinexOfferStatusResponse> GetActiveOffers()
		{
			var activeOffersPost = new BitfinexPostBase
			{
				Request = ActiveOffersRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture)
			};

			var response = GetRestResponse(activeOffersPost);
			var activeOffersResponseObj = JsonConvert.DeserializeObject<IList<BitfinexOfferStatusResponse>>(response);

			Log.Info("Active Offers:");
			foreach (var activeOffer in activeOffersResponseObj)
				Log.Info("Offer: {0}", activeOffer.ToString());

			return activeOffersResponseObj;
		}

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static BitfinexOrderBookGet GetOrderBook(BtcInfo.PairTypeEnum pairType, int limitBids = 30, int limitAsks = 30)
		{
			try
			{
				var url = DepthOfBookRequestUrl + Enum.GetName(typeof(BtcInfo.PairTypeEnum), pairType);
				var response = WebApi.GetBaseResponse(url + string.Format("?limit_bids={0};limit_asks={1}", limitBids, limitAsks));
				var orderBookResponseObj = JsonConvert.DeserializeObject<BitfinexOrderBookGet>(response);
				return orderBookResponseObj;
			}
			catch (Exception ex)
			{
				Log.Error(ex);
				return new BitfinexOrderBookGet();
			}
		}

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static IList<BitfinexSymbolDetailsResponse> GetSymbols()
		{
			const string url = SymbolDetailsRequestUrl;
			var response = WebApi.GetBaseResponse(url);
			var symbolsResponseObj = JsonConvert.DeserializeObject<IList<BitfinexSymbolDetailsResponse>>(response);

			foreach (var bitfinexSymbolDetailsResponse in symbolsResponseObj)
				Log.Info("Symbol: {0}", bitfinexSymbolDetailsResponse);

			return symbolsResponseObj;
		}

19 View Source File : TimedTaskForm.cs
License : Apache License 2.0
Project Creator : 214175590

public void init()
        {
            ThreadPool.QueueUserWorkItem((a) =>
            {
                this.BeginInvoke((MethodInvoker)delegate()
                {
                    string json = YSTools.YSFile.readFileToString(MainForm.CONF_DIR + "shell_temp.json");
                    JObject obj = JsonConvert.DeserializeObject<JObject>(json);
                    JObject shellTemp = (JObject)obj["task_shell_temp"][typeArr[index]];
                    if (null != shellTemp)
                    {
                        ListViewItem item = null;
                        ListViewItem.ListViewSubItem subItem = null;
                        foreach (var o in shellTemp)
                        {
                            item = new ListViewItem();
                            item.Tag = o;
                            item.Text = o.Key;

                            subItem = new ListViewItem.ListViewSubItem();
                            subItem.Text = o.Value.ToString();

                            item.SubItems.Add(subItem);
                            scb_template.Items.Add(item);
                        }
                    }

                    JArray varsTemp = (JArray)obj["vars_temp"][typeArr[index]];
                    if (null != varsTemp)
                    {
                        ListViewItem item = null;
                        ListViewItem.ListViewSubItem subItem = null;
                        foreach (var o in varsTemp)
                        {
                            item = new ListViewItem();
                            item.Tag = o;
                            item.Text = o["value"].ToString();

                            subItem = new ListViewItem.ListViewSubItem();
                            subItem.Text = o["desc"].ToString();

                            item.SubItems.Add(subItem);
                            var_list.Items.Add(item);
                        }
                    }

                });
            });
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static IList<BitfinexLendsResponse> GetLends(string symbol)
		{
			var url = LendsRequestUrl + symbol;
			var response = WebApi.GetBaseResponse(url);

			var lendResponseObj = JsonConvert.DeserializeObject<IList<BitfinexLendsResponse>>(response);
			return lendResponseObj;
		}

19 View Source File : Hentai.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public static HentaiType GetSource(DirectoryInfo dir)
        {
            try
            {
                string input = File.ReadAllText(FileHelper.GetFilePath(dir, "manga.json"));
                MangaInfo info = JsonConvert.DeserializeObject<MangaInfo>(input);
                switch (info.Source)
                {
                    case "nhentai":
                        return HentaiType.NHENTAI;
                    default:
                        return HentaiType.NULL;
                }
            }
            catch (Exception)
            {
                return HentaiType.NULL;
            }
        }

19 View Source File : HuobiAPI.cs
License : MIT License
Project Creator : aabiryukov

public IEnumerable<Order> GetActiveOrders()
		{
			var args = new NameValueCollection
	        {
                {"coin_type", ((int)CoinType.Btc).ToString(CultureInfo.InvariantCulture)},
	        };

			var response = DoMethod2("get_orders", args);
		    var orders = JsonConvert.DeserializeObject<List<Order>>(response);

//			var jsonObject = CheckResult(response);
//			var orders = jsonObject["orders"].ToObject<List<Order>>();

			return orders;
		}

19 View Source File : BTCChinaWebSocketApi.cs
License : MIT License
Project Creator : aabiryukov

private void btc_MessageReceived(object sender, MessageReceivedEventArgs e)
		{
			int eioMessageType;
			if (int.TryParse(e.Message.Substring(0, 1), out eioMessageType))
			{
				switch ((EngineioMessageType)eioMessageType)
				{
					case EngineioMessageType.PING:
						//replace incoming PING with PONG in incoming message and resend it.
						m_webSocket.Send(string.Format(CultureInfo.InvariantCulture, "{0}{1}", (int)EngineioMessageType.PONG, e.Message.Substring(1, e.Message.Length - 1)));
						break;
					case EngineioMessageType.PONG:
						m_pong = true;
						break;

					case EngineioMessageType.MESSAGE:
						int sioMessageType;
						if (int.TryParse(e.Message.Substring(1, 1), out sioMessageType))
						{
							switch ((SocketioMessageType)sioMessageType)
							{
								case SocketioMessageType.CONNECT:
									//Send "42["subscribe",["marketdata_cnybtc","marketdata_cnyltc","marketdata_btcltc"]]"
									m_webSocket.Send(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", (int)EngineioMessageType.MESSAGE,
																	   (int)SocketioMessageType.EVENT,
//																	   "[\"subscribe\",[\"marketdata_cnybtc\",\"marketdata_cnyltc\",\"grouporder_cnybtc\"]]"
																	   "[\"subscribe\",[\"grouporder_cnybtc\"]]"
																	   )
																	   );

									break;

								case SocketioMessageType.EVENT:
									if (e.Message.Substring(4, 5) == "trade")//listen on "trade"
										Log.Info("[BtcChina] TRADE: " + e.Message.Substring(e.Message.IndexOf('{'), e.Message.LastIndexOf('}') - e.Message.IndexOf('{') + 1));
									else
										if (e.Message.Substring(4, 10) == "grouporder")//listen on "trade")
										{
											Log.Info("[BtcChina] grouporder event");

											var json = e.Message.Substring(e.Message.IndexOf('{'), e.Message.LastIndexOf('}') - e.Message.IndexOf('{') + 1);
											var objResponse = JsonConvert.DeserializeObject<WsGroupOrderMessage>(json);
											OnMessageGroupOrder(objResponse.GroupOrder);
										}
										else
										{
											Log.Warn("[BtcChina] Unknown message: " + e.Message.Substring(0, 100));
										}
									break;

								default:
									Log.Error("[BtcChina] error switch socket.io messagetype: " + e.Message);
									break;
							}
						}
						else
						{
							Log.Error("[BtcChina] error parse socket.io messagetype!");
						}
						break;

					default:
						Log.Error("[BtcChina] error switch engine.io messagetype");
						break;
				}
			}
			else
			{
				Log.Error("[BtcChina] error parsing engine.io messagetype!");
			}
		}

19 View Source File : Title.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public static replacedleType GetType(DirectoryInfo dir)
        {
            try
            {
                string input = File.ReadAllText(FileHelper.GetFilePath(dir, "manga.json"));
                MangaInfo info = JsonConvert.DeserializeObject<MangaInfo>(input);
                switch (info.Type)
                {
                    case "manga":
                        return replacedleType.MANGA;
                    case "hentai":
                        return replacedleType.HENTAI;
                    default:
                        return replacedleType.NULL;
                }
            } catch (Exception)
            {
                return replacedleType.NULL;
            }
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public IList<BitfinexMarginPositionResponse> GetActiveOrders()
		{
			var activeOrdersPost = new BitfinexPostBase
			{
				Request = ActiveOrdersRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture)
			};

			var response = GetRestResponse(activeOrdersPost);
			var activeOrdersResponseObj = JsonConvert.DeserializeObject<IList<BitfinexMarginPositionResponse>>(response);

			Log.Info("Active Orders:");
			foreach (var activeOrder in activeOrdersResponseObj)
				Log.Info("Order: {0}", activeOrder.ToString());

			return activeOrdersResponseObj;
		}

19 View Source File : TaskBuild.cs
License : MIT License
Project Creator : 2881099

[JSFunction]
        public string saveTaskBuild(string res)
        {
            try
            {
                var model = JsonConvert.DeserializeObject<Models.TaskBuild>(res);
                Curd.fsql.SetDbContextOptions(o => o.EnableAddOrUpdateNavigateList = false);
                var enreplacedy = Curd.TaskBuild.Insert(model);
                model.TaskBuildInfos.ToList().ForEach(a => a.TaskBuildId = enreplacedy.Id);
                Curd.TaskBuildInfo.Insert(model.TaskBuildInfos);
                var list = Curd.TaskBuild.Select.ToList();
                Data.Clear();
                Data.AddRange(list);
                Data.SaveChanges();
                return JsonConvert.SerializeObject(new { code = 0, msg = "构建任务成功" });
            }
            catch (Exception ex)
            {
                return JsonConvert.SerializeObject(new { code = 1, msg = ex.Message });
            }
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public IList<BitfinexMyTradesResponse> GetMyTrades(string symbol, string timestamp, int limit)
		{
			var myTradesPost = new BitfinexMyTradesPost
			{
				Request = MyTradesRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture),
				Symbol = symbol,
				Timestamp = timestamp,
				Limit = limit
			};

			var response = GetRestResponse(myTradesPost);
			var myTradesResponseObj = JsonConvert.DeserializeObject<IList<BitfinexMyTradesResponse>>(response);

			Log.Info("My Trades:");
			foreach (var myTrade in myTradesResponseObj)
				Log.Info("Trade: {0}", myTrade);

			return myTradesResponseObj;
		}

19 View Source File : MangaDex.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public override void _Load(bool doChapters)
        {
            string input = File.ReadAllText(FileHelper.GetFilePath(mangaRoot, "manga.json"));
            MangaInfo info = JsonConvert.DeserializeObject<MangaInfo>(input);       

            id = info.Id;
            name = info.Name;
            userlang = info.LangCode;
            usergroup = info.Group;
            userreplacedle = info.UserName;
            currentchapter = info.Chapter;
            currentpage = info.Page;
            lastchapter = info.Latest;

            if (doChapters)
                _PopulateChapters();
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public IList<BitfinexBalanceResponse> GetBalances()
		{
			var balancePost = new BitfinexPostBase
			{
				Request = BalanceRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture)
			};

			var response = GetRestResponse(balancePost);
			var balancesObj = JsonConvert.DeserializeObject<IList<BitfinexBalanceResponse>>(response);

			Log.Info("Balances:");
			foreach (var balance in balancesObj)
				Log.Info(balance.ToString());

			return balancesObj;
		}

19 View Source File : Form1.cs
License : MIT License
Project Creator : 200Tigersbloxed

void findMultiplayerVersion()
        {
            string mj;
            string mlj;
            // check for the json data
            if(File.Exists(bsl + @"/UserData/BeatSaberMultiplayer.json"))
            {
                mj = bsl + @"/UserData/BeatSaberMultiplayer.json";
                if (File.Exists(bsl + @"/Plugins/BeatSaberMultiplayer.dll")) {
                    // multiplayer is installed
                    string json = System.IO.File.ReadAllText(mj);
                    dynamic bsmj = JsonConvert.DeserializeObject(json);
                    label8.Text = "Multiplayer Version: " + bsmj["_modVersion"];
                }
                else
                {
                    // no multiplayer
                    label8.Text = "Multiplayer Version: Not Installed";
                }
            }
            else
            {
                // no multiplayer
                label8.Text = "Multiplayer Version: Not Installed";
            }

            if (File.Exists(bsl + @"/UserData/BeatSaberMultiplayer.json"))
            {
                mlj = bsl + @"/UserData/BeatSaberMultiplayerLite.json";
                if (File.Exists(bsl + @"/Plugins/BeatSaberMultiplayerLite.dll"))
                {
                    // multiplayer is installed
                    string json = System.IO.File.ReadAllText(mlj);
                    dynamic bsmj = JsonConvert.DeserializeObject(json);
                    label9.Text = "MultiplayerLite Version: " + bsmj["_modVersion"];
                }
                else
                {
                    // no multiplayer
                    label9.Text = "MultiplayerLite Version: Not Installed";
                }
            }
            else
            {
                // no multiplayer
                label9.Text = "MultiplayerLite Version: Not Installed";
            }
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public BitfinexMarginInfoResponse GetMarginInformation()
		{
			var marginPost = new BitfinexPostBase
			{
				Request = MarginInfoRequstUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture)
			};

			var response = GetRestResponse(marginPost);

			var jArr = JsonConvert.DeserializeObject(response) as JArray;
			if (jArr == null || jArr.Count == 0)
				return null;

			var marginInfoStr = jArr[0].ToString();
			var marginInfoResponseObj = JsonConvert.DeserializeObject<BitfinexMarginInfoResponse>(marginInfoStr);

			Log.Info("Margin Info: {0}", marginInfoResponseObj.ToString());

			return marginInfoResponseObj;
		}

19 View Source File : LanguageHelper.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private Language CreateLanguage(string filename)
        {
            return JsonConvert.DeserializeObject<Language>(GetFileContents(filename));
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public BitfinexOfferStatusResponse SendNewOffer(BitfinexNewOfferPost newOffer)
		{
			newOffer.Request = NewOfferRequestUrl;
			newOffer.Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture);

			var response = GetRestResponse(newOffer);

			var newOfferResponseObj = JsonConvert.DeserializeObject<BitfinexOfferStatusResponse>(response);

			Log.Info("Sending New Offer: {0}", newOffer.ToString());
			Log.Info("Response From Exchange: {0}", newOfferResponseObj);
			return newOfferResponseObj;
		}

19 View Source File : DbList.cs
License : MIT License
Project Creator : 2881099

[JSFunction]
        public void UpdateRow(string jsonStr)
        {
            Data.Clear();

            var enreplacedy = JsonConvert.DeserializeObject<DataBaseConfig>(jsonStr);


            if (string.IsNullOrEmpty(enreplacedy.ConnectionStrings))
            {
                #region 配置数据库连接串
                switch (enreplacedy.DataType)
                {
                    case FreeSql.DataType.MySql:
                        enreplacedy.ConnectionStrings = $"Data Source={enreplacedy.ServerIP};Port={enreplacedy.Port};User ID={enreplacedy.UserName};Preplacedword={enreplacedy.UserPreplaced};Initial Catalog={(string.IsNullOrEmpty(enreplacedy.DataBaseName) ? "mysql" : enreplacedy.DataBaseName)};Charset=utf8;SslMode=none;Max pool size=5";
                        break;
                    case FreeSql.DataType.SqlServer:
                        enreplacedy.ConnectionStrings = $"Data Source={enreplacedy.ServerIP},{enreplacedy.Port};Initial Catalog={enreplacedy.DataBaseName};User ID={enreplacedy.UserName};Preplacedword={enreplacedy.UserPreplaced};Pooling=true;Max Pool Size=5";
                        break;
                    case FreeSql.DataType.PostgreSQL:
                        enreplacedy.ConnectionStrings = $"Host={enreplacedy.ServerIP};Port={enreplacedy.Port};Username={enreplacedy.UserName};Preplacedword={enreplacedy.UserPreplaced};Database={(string.IsNullOrEmpty(enreplacedy.DataBaseName) ? "postgres" : enreplacedy.DataBaseName)};Pooling=true;Maximum Pool Size=5";
                        break;
                    case FreeSql.DataType.Oracle:
                        enreplacedy.ConnectionStrings = $"user id={enreplacedy.UserName};preplacedword={enreplacedy.UserPreplaced};data source=//{enreplacedy.ServerIP}:{enreplacedy.Port}/{enreplacedy.DataBaseName};Pooling=true;Max Pool Size=5";
                        break;
                }
                #endregion
            }
            else if (string.IsNullOrEmpty(enreplacedy.DataBaseName))
            {
                switch(enreplacedy.DataType)
                {
                    case FreeSql.DataType.Oracle:
                        enreplacedy.DataBaseName = Regex.Match(enreplacedy.ConnectionStrings, @"user id=([^;]+)", RegexOptions.IgnoreCase).Groups[1].Value;
                        break;
                    case FreeSql.DataType.MySql:
                        using (var conn = new MySql.Data.MySqlClient.MySqlConnection(enreplacedy.ConnectionStrings))
                        {
                            conn.Open();
                            enreplacedy.DataBaseName = conn.Database;
                            conn.Close();
                        }
                        break;
                    case FreeSql.DataType.SqlServer:
                        using (var conn = new System.Data.SqlClient.SqlConnection(enreplacedy.ConnectionStrings))
                        {
                            conn.Open();
                            enreplacedy.DataBaseName = conn.Database;
                            conn.Close();
                        }
                        break;
                    case FreeSql.DataType.PostgreSQL:
                        using (var conn = new Npgsql.NpgsqlConnection(enreplacedy.ConnectionStrings))
                        {
                            conn.Open();
                            enreplacedy.DataBaseName = conn.Database;
                            conn.Close();
                        }
                        break;
                }
            }

            Curd.DataBase.InsertOrUpdate(enreplacedy);
            var _list = Curd.DataBase.Select.ToList();
            Data.AddRange(_list);
            Data.SaveChanges();





            //InvokeJS("page.$confirm('添加完成, 是否继续?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'})");
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public static List<Trade> GetTrades()
		{
			const string queryStr = "https://" + apiHost + "/data/trades";
			var json = WebApi.Query(queryStr);
			var list = JsonConvert.DeserializeObject<List<Trade>>(json);
			return list;
		}

19 View Source File : Download.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public bool StartDownloading()
        {
            Logger.Log("[DL] Starting Download for '" + manga.mangaDirectory.FullName + "\\" + chapterNumber + "'");
            string chapterDirectory = manga.mangaDirectory.FullName + "\\" + chapterNumber;
            Directory.CreateDirectory(chapterDirectory); // Create a directory for this chapter

            switch (type)
            {
                case DownloadType.MANGA:
                    string jsonUrl = "https://mangadex.org/api/chapter/" + chapterID;
                    string json;
                    using (var wc = new System.Net.WebClient())
                        json = wc.DownloadString(jsonUrl);

                    dynamic contents = JsonConvert.DeserializeObject(json);
                    string server = contents.server;
                    string hash = contents.hash;
                    foreach (string file in contents.page_array)
                    {
                        if (server == "/data/")
                        {
                            server = "https://mangadex.org/data/";
                        }
                        string imgUrl = server + hash + "/" + file;
                        string imgFile = chapterDirectory + "\\" + file;

                        if (File.Exists(imgFile))
                        {
                            long length = new FileInfo(imgFile).Length;
                            if (length <= 0)
                            {
                                File.Delete(imgFile);
                            }
                        }
                        try
                        {
                            DownloadAsync(new Uri(imgUrl), imgFile);
                        } catch (Exception ex)
                        {
                            Logger.Error("[DL] Failed to download '" + imgUrl + "' because '" + ex.Message + "'");
                        }
                    }
                    CheckStartNext();
                    return true;

                case DownloadType.HENTAI:
                    string imageUrl = string.Empty;
                    string extension;
                    int pageCount = 0;
                    imageUrl = NHGetImageUrl(url);
                    pageCount = NHGetPageCount(url);
                    extension = NHGetImageExtension(imageUrl);
                    string imgLoc = NHGetImageLocation(imageUrl);

                    for (int page = 1; page <= pageCount; page++)
                    {
                        dlCount++;
                        string curImgUrl = imgLoc + page + "." + extension;
                        string imgFile = chapterDirectory + "\\" + page + "." + extension;
                        if (File.Exists(imgFile))
                        {
                            long length = new FileInfo(imgFile).Length;
                            if (length <= 0)
                            {
                                File.Delete(imgFile);
                                DownloadAsync(new Uri(curImgUrl), imgFile);
                            }
                            else
                            {
                                if (page == pageCount) // last one
                                    CheckStartNext();
                            }
                        }
                        else
                            DownloadAsync(new Uri(curImgUrl), imgFile);
                    }
                    return true;
                default:
                    return false;
            }
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public static OrderBook GetOrderBook(int limit)
		{
			var queryStr = string.Format(CultureInfo.InvariantCulture, "https://" + apiHost + "/data/orderbook?limit={0}", limit);
			var json = WebApi.Query(queryStr);
			var book = JsonConvert.DeserializeObject<OrderBook>(json);
			return book;
		}

19 View Source File : Settings.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish

public static void readSettingFile()
    {
        try
        {
            var JsonData = JsonConvert.DeserializeObject<SettingJson>(File.ReadAllText(SETTING_FILE));
            jsonSetting = JsonData;
        }
        catch (Exception)
        {
            SteamTwoProperties.reset();
            SteamTwoProperties.updateSettingFile();
        }
    }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public BitfinexOfferStatusResponse GetOfferStatus(int offerId)
		{
			var statusPost = new BitfinexOfferStatusPost
			{
				Request = OfferStatusRequestUrl,
				Nonce = Common.UnixTimeStampUtc().ToString(CultureInfo.InvariantCulture),
				OfferId = offerId
			};

			var response = GetRestResponse(statusPost);
			var offerStatuslResponseObj = JsonConvert.DeserializeObject<BitfinexOfferStatusResponse>(response);

			Log.Info("Status of offerId: {0}. Exchange response: {1}", offerId, offerStatuslResponseObj);

			return offerStatuslResponseObj;
		}

19 View Source File : GUISettings.cs
License : MIT License
Project Creator : a1xd

public static GUISettings MaybeLoad()
        {
            GUISettings settings = null;

            try
            {
                settings = JsonConvert.DeserializeObject<GUISettings>(
                    File.ReadAllText(Constants.GuiConfigFileName));
            }
            catch (Exception ex)
            {
                if (!(ex is JsonException || ex is FileNotFoundException))
                {
                    throw;
                }
            }

            return settings;
        }

19 View Source File : JsonFile.cs
License : Apache License 2.0
Project Creator : 42skillz

public static T ReadFromJsonFile<T>(string filePath) where T : new()
        {
            TextReader reader = null;
            try
            {
                reader = new StreamReader(filePath);
                var fileContents = reader.ReadToEnd();
                return JsonConvert.DeserializeObject<T>(fileContents);
            }
            finally
            {
                reader?.Close();
            }
        }

19 View Source File : MainWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish

private void getAccountData()
        {
            var JsonAccounts = JsonConvert.DeserializeObject<jsonObject>(File.ReadAllText(SAVE_FILE_NAME));
            for (int i = 0; i < JsonAccounts.count; i++)
            {
                AccountController.addAccount(JsonAccounts.accounts[i].username, JsonAccounts.accounts[i].preplacedword, JsonAccounts.accounts[i].desktopAuth);
            }
        }

19 View Source File : AppConfig.cs
License : Apache License 2.0
Project Creator : 214175590

public void LoadConfig()
        {
            // 初始化主配置            
            try
            {
                MainConfig config = null;
                if (File.Exists(MainForm.CONF_DIR + MC_NAME))
                {
                    string mconfig = YSTools.YSFile.readFileToString(MainForm.CONF_DIR + MC_NAME, false, CONFIG_KEY);
                    if (!string.IsNullOrWhiteSpace(mconfig))
                    {
                        config = JsonConvert.DeserializeObject<MainConfig>(mconfig);
                        if(null != config){
                            MConfig = config;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("加载Main配置文件异常:" + ex.Message);
                logger.Error("--->" + MC_NAME);
            }

            // 初始化session配置
            SessionConfigDict = new Dictionary<string, SessionConfig>();

            DirectoryInfo direct = new DirectoryInfo(MainForm.SESSION_DIR);
            if (direct.Exists)
            {
                FileInfo[] files = direct.GetFiles();
                string content = null;
                SessionConfig sessionConfig = null;
                foreach(FileInfo file in files){
                    try
                    {
                        if (file.Name.EndsWith(".json"))
                        {
                            content = YSTools.YSFile.readFileToString(file.FullName, false, CONFIG_KEY);
                            if (!string.IsNullOrWhiteSpace(content))
                            {
                                sessionConfig = JsonConvert.DeserializeObject<SessionConfig>(content);
                                if (null != sessionConfig)
                                {
                                    SessionConfigDict.Add(sessionConfig.SessionId, sessionConfig);
                                }
                            }                            
                        }
                    }catch(Exception ex){
                        logger.Error("加载Session配置文件异常:" + ex.Message);
                        logger.Error("--->" + file.Name);
                    }                    
                }
            }

        }

19 View Source File : TaskBuild.cs
License : MIT License
Project Creator : 2881099

[JSFunction]
        public async Task CodeGenerates(string jsonStr)
        {

            var ids =  Newtonsoft.Json.JsonConvert.DeserializeObject<string[]>(jsonStr);       
            foreach(var id in ids)
            {              
                if (Guid.TryParse(id, out Guid gid) && gid != Guid.Empty)
                {                 
                    var model = Curd.TaskBuild.Select.WhereDynamic(gid)
                       .LeftJoin(a => a.Templates.Id == a.TemplatesId)
                       .IncludeMany(a => a.TaskBuildInfos, b => b.Include(p => p.DataBaseConfig))
                       .ToOne();
                    InvokeJS($"$('.helper-loading-text').text('正在生成[{model.TaskName}]请稍后....')");
                    await Task.Delay(500);
                    var res = await new CodeGenerate().Setup(model);                                       
                    InvokeJS($"$('.helper-loading-text').text('[{model.TaskName}]{res}')");
                    if(res.Contains("发生异常")) await Task.Delay(3000);

                }
                else
                {
                    InvokeJS("Helper.ui.alert.error('生成失败','参数不是有效的.');");
                }
            }
            await Task.FromResult(0);
            InvokeJS("Helper.ui.removeDialog();");
           
            
        }

19 View Source File : Manga.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public static MangaType GetSource(DirectoryInfo dir)
        {
            try
            {
                string input = File.ReadAllText(FileHelper.GetFilePath(dir, "manga.json"));
                MangaInfo info = JsonConvert.DeserializeObject<MangaInfo>(input);
                switch (info.Source)
                {
                    case "mangadex":
                        return MangaType.MANGADEX;
                    case "kissmanga":
                        return MangaType.KISSMANGA;
                    default:
                        return MangaType.NULL;
                }
            }
            catch (Exception)
            {
                return MangaType.NULL;
            }
        }

19 View Source File : HuobiAPI.cs
License : MIT License
Project Creator : aabiryukov

private int InternalTrade(decimal price, decimal amount, bool isSell)
	    {
	        var method = isSell ? "sell" : "buy";
            var args = new NameValueCollection
	        {
		        {"coin_type", ((int)CoinType.Btc).ToString(CultureInfo.InvariantCulture)},
				{"price", price.ToString(CultureInfo.InvariantCulture)},
				{"amount", amount.ToString(CultureInfo.InvariantCulture)}
	        };

			var response = DoMethod2(method, args);
	        var orderResult = JsonConvert.DeserializeObject<HuobiOrderResult>(response);
            if(orderResult.Result != "success")
                throw new HuobiException(method, "Failed to create order: " + method);

            if (orderResult.Id > int.MaxValue)
                throw new HuobiException(method, "Order value too large for int: " + orderResult.Id);

            return (int)orderResult.Id;
		}

See More Examples