private void UpdateServices() { this._services = new List <IStockQuoteService>(); foreach (var item in _settings) { IStockQuoteService service = null; if (AlphaVantage.IsMySettings(item)) { service = new AlphaVantage(item, this.LogPath); } else if (IEXTrading.IsMySettings(item)) { service = new IEXTrading(item, this.LogPath); } if (service != null) { service.DownloadError += OnServiceDownloadError; service.QuoteAvailable += OnServiceQuoteAvailable; service.Complete += OnServiceQuotesComplete; service.Suspended += OnServiceSuspended; service.SymbolNotFound += OnSymbolNotFound; this._services.Add(service); } } }
protected void Page_Load(object sender, EventArgs e) { this.stockQuoteService = new RandomStockQuoteService(); if (!this.IsPostBack) { UpdateQuotes(); } }
void BeginGetQuotes(HashSet <Security> toFetch) { if (_services.Count == 0 || toFetch.Count == 0) { return; } UiDispatcher.BeginInvoke(new Action(() => { OutputPane output = (OutputPane)provider.GetService(typeof(OutputPane)); output.Clear(); output.AppendHeading(Walkabout.Properties.Resources.StockQuoteCaption); })); List <string> batch = new List <string>(); foreach (Security s in toFetch) { if (string.IsNullOrEmpty(s.Symbol)) { continue; // skip it. } batch.Add(s.Symbol); } bool foundService = false; IStockQuoteService service = GetHistoryService(); HistoryDownloader downloader = GetDownloader(service); if (service != null) { downloader.BeginFetchHistory(batch); foundService = true; } service = GetQuoteService(); if (service != null) { foundService = true; if (service.SupportsBatchQuotes) { service.BeginFetchQuotes(batch); } else { foreach (var item in batch) { service.BeginFetchQuote(item); } } } if (!foundService) { AddError(Walkabout.Properties.Resources.ConfigureStockQuoteService); UiDispatcher.BeginInvoke(new Action(UpdateUI)); } }
private HistoryDownloader GetDownloader(IStockQuoteService service) { if (_downloader == null) { _downloader = new HistoryDownloader(service, this._downloadLog); _downloader.Error += OnDownloadError; _downloader.HistoryAvailable += OnHistoryAvailable; } return(_downloader); }
public StocksTickerPresenter( IStocksTickerView view, IStockQuoteService stockQuoteService) { this.view = view; this.stockQuoteService = stockQuoteService; this.view.Subscribe += this.OnSubscribe; this.view.Unsubscribe += this.OnUnsubscribe; this.view.RefreshEnabledChanged += this.OnRefreshEnabledChanged; this.refreshTimer = new System.Timers.Timer(); this.refreshTimer.AutoReset = false; this.refreshTimer.Elapsed += this.OnRefreshTimerElapsed; this.RefreshInterval = 5; // default refresh interval this.logger = new NullLogger(); }
private IStockQuoteService GetQuoteService() { IStockQuoteService result = null; foreach (var service in _services) { if (service.IsEnabled) { if (service.SupportsBatchQuotes) { return(service); } if (result == null) { result = service; } } } return(result); }
static void Main(string[] args) { ChannelFactory <IStockQuoteService> tcpChanelFactory = new ChannelFactory <IStockQuoteService>("tcpEndpoint"); ChannelFactory <IStockQuoteService> pipeChanelFactory = new ChannelFactory <IStockQuoteService>("pipeEndpoint"); ChannelFactory <IStockQuoteService> httpChanelFactory = new ChannelFactory <IStockQuoteService>("httpEndpoint"); ChannelFactory <IStockQuoteService> wsHttpChanelFactory = new ChannelFactory <IStockQuoteService>("wsHttpEndpoint"); ChannelFactory <IStockQuoteService> ws2007HttpChanelFactory = new ChannelFactory <IStockQuoteService>("ws2007HttpEndpoint"); ChannelFactory <IStockQuoteService> cutomBindingChanelFactory = new ChannelFactory <IStockQuoteService>("customBinding"); //Consuming Two one-way duplex service waitForResponse = new AutoResetEvent(false); InstanceContext callBackInstance = new InstanceContext(new Program()); using (StockQuoteDuplexServiceClient client = new StockQuoteDuplexServiceClient(callBackInstance)) { client.SendQuoteRequest("MSFT"); waitForResponse.WaitOne(); } // IStockQuoteService tcpClient = tcpChanelFactory.CreateChannel(); IStockQuoteService pipeClient = pipeChanelFactory.CreateChannel(); IStockQuoteService httpClient = httpChanelFactory.CreateChannel(); IStockQuoteService wsHttpClient = wsHttpChanelFactory.CreateChannel(); IStockQuoteService ws2007HttpClient = ws2007HttpChanelFactory.CreateChannel(); IStockQuoteService customBindingHttpClient = cutomBindingChanelFactory.CreateChannel(); Console.WriteLine("TCP client : {0}", tcpClient.GetQuote("YHOO")); Console.WriteLine("Pipe client : {0}", pipeClient.GetQuote("YHOO")); Console.WriteLine("HTTP client : {0}", httpClient.GetQuote("YHOO")); Console.WriteLine("WS HTTP client : {0}", wsHttpClient.GetQuote("YHOO")); Console.WriteLine("WS2007 HTTP client : {0}", ws2007HttpClient.GetQuote("YHOO")); Console.WriteLine("Custom Binding TCP client : {0}", customBindingHttpClient.GetQuote("YHOO")); StockQuoteResponse.MsMqStarService(); Console.ReadLine(); }
public StocksTickerController(IStockQuoteService service) { this.service = service; }
/// <summary> /// Initializes this object /// </summary> /// <param name="stockQuoteService">The stock quote service</param> public PriceCalculatorService(IStockQuoteService stockQuoteService) { _stockQuoteService = stockQuoteService; }
public StockAnalyzerService(IStockHoldingService holdingsService, IStockQuoteService stockQuoteService) { _holdingsService = holdingsService; _stockQuoteService = stockQuoteService; }
public StocksTickerController() { this.service = new RandomStockQuoteService(); }
public StockQuoteController(IStockQuoteService stockQuoteService) { _stockQuoteService = stockQuoteService; }
public StockQuoteController(ILogger <StockQuoteController> logger, IStockQuoteService stockQuoteService) { _logger = logger; _stockQuoteService = stockQuoteService; }
/// <summary> /// Initializes a new instance of the <see cref="StockViewModel"/> class. /// </summary> /// <param name="stockQuoteService"> /// The stock quote service. /// </param> public StockViewModel(IStockQuoteService stockQuoteService) { this.stockQuoteService = stockQuoteService; this.StockQuotes = new ObservableDataSource<Stock>(); }
public GetStockQuoteFunction(IStockQuoteService stockQuoteService, ILogger <GetStockQuoteFunction> logger) { _stockQuoteService = stockQuoteService; _logger = logger; }
public MainForm(IPortfolioService portfolioService, IStockQuoteService stockQuoteService) { _portfolioService = portfolioService; _stockQuoteService = stockQuoteService; InitializeComponent(); }
// backend service implementation gets injected through dependency injection public StockQuoteFunction(IStockQuoteService stockQuoteServiceClient) { _stockQuoteService = stockQuoteServiceClient; }
/// <summary> /// Initializes a new instance of the <see cref="StockViewModel"/> class. /// </summary> /// <param name="stockQuoteService"> /// The stock quote service. /// </param> public StockViewModel(IStockQuoteService stockQuoteService) { this.stockQuoteService = stockQuoteService; this.StockQuotes = new ObservableDataSource <Stock>(); }
public HistoryDownloader(IStockQuoteService service, DownloadLog log) { _service = service; _downloadLog = log; }
public ChatHub(IStockQuoteService quoteService) { _quoteService = quoteService; }