コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.stockQuoteService = new RandomStockQuoteService();
     if (!this.IsPostBack)
     {
         UpdateQuotes();
     }
 }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
 private HistoryDownloader GetDownloader(IStockQuoteService service)
 {
     if (_downloader == null)
     {
         _downloader                   = new HistoryDownloader(service, this._downloadLog);
         _downloader.Error            += OnDownloadError;
         _downloader.HistoryAvailable += OnHistoryAvailable;
     }
     return(_downloader);
 }
コード例 #5
0
        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();
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: popovsli/GeneratedClient
        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();
        }
コード例 #9
0
 public StocksTickerController(IStockQuoteService service)
 {
     this.service = service;
 }
コード例 #10
0
 /// <summary>
 /// Initializes this object
 /// </summary>
 /// <param name="stockQuoteService">The stock quote service</param>
 public PriceCalculatorService(IStockQuoteService stockQuoteService)
 {
     _stockQuoteService = stockQuoteService;
 }
コード例 #11
0
 public StockAnalyzerService(IStockHoldingService holdingsService, IStockQuoteService stockQuoteService)
 {
     _holdingsService   = holdingsService;
     _stockQuoteService = stockQuoteService;
 }
コード例 #12
0
 public StocksTickerController()
 {
     this.service = new RandomStockQuoteService();
 }
コード例 #13
0
 public StockQuoteController(IStockQuoteService stockQuoteService)
 {
     _stockQuoteService = stockQuoteService;
 }
コード例 #14
0
 public StocksTickerController(IStockQuoteService service)
 {
     this.service = service;
 }
コード例 #15
0
 public StockQuoteController(ILogger <StockQuoteController> logger, IStockQuoteService stockQuoteService)
 {
     _logger            = logger;
     _stockQuoteService = stockQuoteService;
 }
コード例 #16
0
 /// <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>();
 }
コード例 #17
0
 public StocksTickerController()
 {
     this.service = new RandomStockQuoteService();
 }
コード例 #18
0
 public GetStockQuoteFunction(IStockQuoteService stockQuoteService, ILogger <GetStockQuoteFunction> logger)
 {
     _stockQuoteService = stockQuoteService;
     _logger            = logger;
 }
コード例 #19
0
 public MainForm(IPortfolioService portfolioService, IStockQuoteService stockQuoteService)
 {
     _portfolioService  = portfolioService;
     _stockQuoteService = stockQuoteService;
     InitializeComponent();
 }
コード例 #20
0
 // backend service implementation gets injected through dependency injection
 public StockQuoteFunction(IStockQuoteService stockQuoteServiceClient)
 {
     _stockQuoteService = stockQuoteServiceClient;
 }
コード例 #21
0
 /// <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>();
 }
コード例 #22
0
 public HistoryDownloader(IStockQuoteService service, DownloadLog log)
 {
     _service     = service;
     _downloadLog = log;
 }
コード例 #23
0
ファイル: ChatHub.cs プロジェクト: lyonn19/StockQuoteChat
 public ChatHub(IStockQuoteService quoteService)
 {
     _quoteService = quoteService;
 }