public StockService(IHttpClientFactory httpClientFactory, StockServiceSettings stockServiceSettings, ILogger <StockService> logger) { _stockServiceSettings = stockServiceSettings; _httpClientFactory = httpClientFactory; _logger = logger; }
public void Setup() { _fakeHttpClientFactory = new Mock <IHttpClientFactory>(); _fakeLogger = new Mock <ILogger <StockService> >(); _stockServiceSettings = new StockServiceSettings { Url = "https://google.com" }; // }
public void ReadXml(XmlReader r) { r.MoveToContent(); while (r.Read()) { if (r.NodeType == XmlNodeType.Element && !r.IsEmptyElement) { PropertyInfo pi = this.GetType().GetProperty(r.Name); if (pi != null) { Type t = pi.PropertyType; if (t == typeof(Point)) { pi.SetValue(this, DeserializePoint(r), null); } else if (t == typeof(Size)) { pi.SetValue(this, DeserializeSize(r), null); } else if (t == typeof(int)) { pi.SetValue(this, Int32.Parse(r.ReadString()), null); } else if (t == typeof(string)) { pi.SetValue(this, r.ReadString(), null); } else if (t == typeof(string[])) { List <string> items = new List <string>(); while (r.Read() && r.NodeType != XmlNodeType.EndElement) { if (r.NodeType == XmlNodeType.Element && r.LocalName == "item") { if (!r.IsEmptyElement) { var value = r.ReadElementContentAsString(); items.Add(value); } } } pi.SetValue(this, items.ToArray(), null); } else if (t == typeof(XmlElement)) { pi.SetValue(this, (XmlElement)doc.ReadNode(r), null); } else if (t == typeof(GraphState)) { pi.SetValue(this, GraphState.ReadFrom(r), null); } else if (t == typeof(DateTime)) { pi.SetValue(this, DeserializeDateTime(r), null); } else if (t == typeof(TimeSpan)) { pi.SetValue(this, DeserializeTimeSpan(r), null); } else if (t == typeof(bool)) { pi.SetValue(this, bool.Parse(r.ReadString()), null); } else if (t == typeof(QueryRow[])) { pi.SetValue(this, ReadQuery(r), null); } else if (t == typeof(List <StockServiceSettings>)) { StockServiceSettings s = new StockServiceSettings(); s.Deserialize(r); if (this.StockServiceSettings == null) { this.StockServiceSettings = new List <StockServiceSettings>(); } this.StockServiceSettings.Add(s); } else { throw new Exception("Settings.ReadXml encountered unsupported property type '" + t.FullName + "'"); } } else if (r.Name == "ViewState") { // backwards compat for old TransactionViewState slot. this.SetViewStateNode(typeof(TransactionsView), (XmlElement)doc.ReadNode(r)); } else if (r.Name == "Password") { // removing passwords from the settings file! } else { string viewType = r.GetAttribute("ViewType"); if (!string.IsNullOrWhiteSpace(viewType)) { Type t = typeof(Settings).Assembly.GetType(viewType); if (t != null && typeof(IView).IsAssignableFrom(t)) { // special case...we don't know how to deserialize these so we leave it for later. this.SetViewStateNode(t, (XmlElement)doc.ReadNode(r)); } } else { map[r.Name] = r.ReadString(); } } } } }
private void Apply() { int i = this.ComboServiceName.SelectedIndex; _selection = _list[i]; }