public void Copy(StockType stock) { this.Showapi_Res_Code = stock.Showapi_Res_Code; this.Showapi_Res_Error = stock.Showapi_Res_Error; this.Code = stock.Code; this.Showapi_Res_Body.IndexList = stock.Showapi_Res_Body.IndexList; this.Showapi_Res_Body.K_Pic = stock.Showapi_Res_Body.K_Pic; this.Showapi_Res_Body.Ret_Code = stock.Showapi_Res_Body.Ret_Code; this.Showapi_Res_Body.StockMarket = stock.Showapi_Res_Body.StockMarket; }
public bool deserialize(String code) { String json = new ShowApiRequest(ShowAPI.URL[1], ShowAPI.APPID, ShowAPI.SECRET) .addTextPara("code", code) .post(); JavaScriptSerializer serializer = new JavaScriptSerializer(); //var json = serializer.Serialize(p); var obj = serializer.Deserialize <StockType>(json); if (obj.Showapi_Res_Code == 0) { if (obj.Showapi_Res_Body.Ret_Code == 0) { if (debug) { Console.WriteLine("[INFO] Code: " + obj.Showapi_Res_Code + " <OK>."); } //Console.WriteLine(ReferenceEquals(p,p1)); stk_model = obj; stk_model.Code = code; return(true); } else { System.Windows.Forms.MessageBox.Show("操作不存在的代码.", "错误", System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore, System.Windows.Forms.MessageBoxIcon.Warning); } } else { Console.Error.WriteLine("[ERR] Code: " + obj.Showapi_Res_Code + " => Error: " + obj.Showapi_Res_Error + "."); } stk_model = new StockType(); stk_model.Code = code; return(false); }
public bool deserialize(String code) { String json = new ShowApiRequest(ShowAPI.URL[1], ShowAPI.APPID, ShowAPI.SECRET) .addTextPara("code", code) .post(); JavaScriptSerializer serializer = new JavaScriptSerializer(); //var json = serializer.Serialize(p); var obj = serializer.Deserialize<StockType>(json); if (obj.Showapi_Res_Code == 0) { if (obj.Showapi_Res_Body.Ret_Code == 0) { if (debug) Console.WriteLine("[INFO] Code: " + obj.Showapi_Res_Code + " <OK>."); //Console.WriteLine(ReferenceEquals(p,p1)); stk_model = obj; stk_model.Code = code; return true; } else { System.Windows.Forms.MessageBox.Show("操作不存在的代码.", "错误", System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore, System.Windows.Forms.MessageBoxIcon.Warning); } } else { Console.Error.WriteLine("[ERR] Code: " + obj.Showapi_Res_Code + " => Error: " + obj.Showapi_Res_Error + "."); } stk_model = new StockType(); stk_model.Code = code; return false; }