public MainWindow()
 {
     InitializeComponent();
     this.Loaded += MainWindowLoaded;
     this._proxy  = new StockClient();
     this.LbStocks.ItemsSource = this.Stocks;
 }
 public StockTickerHub(StockHubConnection stockHubConnection, IHubContext <StockTickerHub> hub, StockClient stockClient, ILogger logger)
 {
     StockHubConnection = stockHubConnection.HubConnection;
     Hub         = hub;
     StockClient = stockClient;
     _logger     = logger;
 }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            this._proxyPubSub        = new PubSubClient(new InstanceContext(this));
            this._proxyStock         = new StockClient();
            this._syncContext        = SynchronizationContext.Current;
            this.LbShare.ItemsSource = this.Buyers;
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            eStockClient stock_Clnt = new StockClient("NetTcpBinding_IStock");
            string       address    = stock_Clnt.Endpoint.Address.ToString();
            string       stock      = stock_Clnt.GetData(100);

            Console.WriteLine("Food Stock : {0} ", stock);
            Console.ReadLine();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // 构造客户端.
            StockClient client = new StockClient();

            client.SendMessage();


            Console.ReadLine();
        }
 public StockTicker(IHubContext <StockTickerHub> hub, StockClient stockClient, Serilog.ILogger logger)
 {
     Hub = hub ??
           throw new ArgumentNullException(nameof(hub));
     _stockClient = stockClient ??
                    throw new ArgumentNullException(nameof(stockClient));
     _logger = logger ??
               throw new ArgumentNullException(nameof(logger));
     UpdateStockValues();
 }
Ejemplo n.º 7
0
        public void Execute()
        {
            if (!Input.ContainsKey("Quantity"))
            {
                throw new ArgumentException("Quantity not passed");
            }
            var quantity = (int)Input["Quantity"];
            var msg      = StockClient.StockUpdate(quantity);

            Output.Add("StockMessage", msg);
            _logger.LogInformation(msg);
        }
Ejemplo n.º 8
0
        public async Task Should_ReturnNotUnderstoodMessage_When_StockQuoteNameIsWrong()
        {
            // Arrange
            IStockClient service    = new StockClient();
            string       stockQuote = "appl.us"; // quote name wrong

            // Act
            var actual = await service.GetStockQuote(stockQuote);

            // Assert
            Assert.AreEqual("We couldn´t understood your query, check your stock name", actual.Message);
        }
Ejemplo n.º 9
0
        public async Task Should_ReturnQuoteObject_When_StockQuoteNameIsOK()
        {
            // Arrange
            IStockClient service    = new StockClient();
            string       stockQuote = "aapl.us"; // quote name ok

            // Act
            var actual = await service.GetStockQuote(stockQuote);

            // Assert
            Assert.IsInstanceOfType(actual, typeof(Quote));
        }
Ejemplo n.º 10
0
        public async Task GetStockQuoteSimpleTestAsync()
        {
            // Arrange
            IStockClient service    = new StockClient();
            string       stockQuote = "aapl.us";

            // Act
            var actual = await service.GetStockQuote(stockQuote);

            // Assert
            Assert.AreEqual("AAPL.US", actual.Symbol);
        }
        private async Task <string> GetStockPrice(string symbol)
        {
            double?stockPrice = await StockClient.GetStockPriceAsync(symbol);

            if (stockPrice == null)
            {
                return($"{symbol.ToUpper()} doesn't appear to be a valid stock symbol.");
            }
            else
            {
                return($"The current value of {symbol.ToUpper()} is ${stockPrice.ToString()}");
            }
        }
        public Dictionary <string, object> Execute(Dictionary <string, object> Input)
        {
            Dictionary <string, object> Output = new Dictionary <string, object>();

            if (!Input.ContainsKey("Quantity"))
            {
                throw new ArgumentException("Quantity not passed");
            }
            var quantity = (int)Input["Quantity"];
            var msg      = StockClient.StockUpdate(quantity);

            Output.Add("StockMessage", msg);
            _logger.LogInformation(msg);
            return(Output);
        }
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var stockCollector = new StockCollector();
            var stockClient    = new StockClient();
            var observable     = stockCollector.StocksStream(TimeSpan.FromSeconds(3), stoppingToken)
                                 .Where(stocks => stocks.Any())
                                 .DistinctUntilChanged()
                                 .Do(stocks => stockClient.AddRange(stocks))
                                 .Catch <IEnumerable <Stock>, Exception> (ex => {
                Console.WriteLine("[Error] " + DateTime.Now + " Catch: " + ex.Message + " : " + ex.StackTrace);
                return(Observable.Empty <IEnumerable <Stock> > ());
            });

            using (var stocks = observable.Subscribe()) {
                Console.WriteLine(DateTime.Now + " Press any key to unsubscribe");
                observable.Wait();
            }
            return(Task.CompletedTask);
        }
Ejemplo n.º 14
0
        public void RollBack()
        {
            if (!Input.ContainsKey("Quantity"))
            {
                throw new ArgumentException("Quantity not passed");
            }
            var quantity    = (int)Input["Quantity"];
            int rollbackqty = quantity * -1;
            var msg         = StockClient.StockUpdate(rollbackqty);

            if (Output.ContainsKey("StockMessage"))
            {
                Output["StockMessage"] = msg;
            }
            else
            {
                Output.Add("StockMessage", msg);
            }

            _logger.LogInformation(msg);
        }
        public Dictionary <string, object> RollBack(Dictionary <string, object> Input)
        {
            Dictionary <string, object> Output = new Dictionary <string, object>();

            if (!Input.ContainsKey("Quantity"))
            {
                throw new ArgumentException("Quantity not passed");
            }
            var quantity    = (int)Input["Quantity"];
            int rollbackqty = quantity * -1;
            var msg         = StockClient.StockUpdate(rollbackqty);

            if (Output.ContainsKey("StockMessage"))
            {
                Output["StockMessage"] = msg;
            }
            else
            {
                Output.Add("StockMessage", msg);
            }

            _logger.LogInformation(msg);
            return(Output);
        }
 public IEnumerable <Stock> GetAllStocks()
 {
     return(StockClient.GetAllStocks().GetAwaiter().GetResult());
 }