internal static YqlChartResponse Catch(string ticker) { #region Validate ticker if (string.IsNullOrEmpty(ticker)) return new YqlChartResponse() { Success = new Success() { State = SuccessState.NoData, Information = "No Ticker was given" } }; #endregion Validate ticker #region Get Data in raw form --> string reply string reply = string.Empty; try { reply = DownloadData(ticker); } catch (Exception ex) { return new YqlChartResponse() { Success = new Success() { State = SuccessState.Error, Information = "Error During Data Download", ErrorInformation = ex.InnerException.ToString() } }; } #endregion Get Data in raw form --> string reply #region Convert raw data to objects --> RootObject data var data = new RootObject(); try { data = Deserialize(reply); } catch (Exception ex) { return new YqlChartResponse() { Success = new Success() { State = SuccessState.Error, Information = "Error During Deserializing", ErrorInformation = ex.InnerException.ToString() + "\n\nData: " + reply } }; } #endregion Convert raw data to objects --> RootObject data #region Return return new YqlChartResponse() { Success = new Success() { State = SuccessState.Success}, Data = data }; #endregion Return }
internal YqlChartResponse() { Success = new Success(); Data = new RootObject(); }