Esempio n. 1
0
        public TradeSimulator(ILogger logger, RequestSender requestSender)
        {
            this.logger        = logger;
            this.requestSender = requestSender;

            logger.InitLogger();
            uniformRandomiser = new Random();
        }
Esempio n. 2
0
        static string GetRequestResult(string userInput, RequestSender requestSender, IEnumerable <IRequestStrategy> strategies)
        {
            string[] splittedUserInpit = userInput.Split(' ', '\t');
            var      strategy          = strategies.FirstOrDefault(x => x.CanExicute(splittedUserInpit[0]));

            if (strategy == null)
            {
                return("Unknown command");
            }
            return(strategy.Run(splittedUserInpit, requestSender));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var           container     = new Container(new TradingRegistry());
            string        exitKey       = "e";
            string        userInput     = "";
            RequestSender requestSender = container.GetInstance <RequestSender>();

            Console.WriteLine($"{DateTime.Now} Client started");
            Timer timer = new Timer(10000)
            {
                AutoReset = true
            };

            timer.Elapsed += (sender, e) => { container.GetInstance <TradeSimulator>().ClientsTrade(); };
            timer.Start();

            IEnumerable <IRequestStrategy> strategies = InitializeRequestStrategy();

            while (!userInput.ToLower().Equals(exitKey))
            {
                userInput = Console.ReadLine();
                Console.WriteLine(GetRequestResult(userInput, requestSender, strategies));
            }
        }