예제 #1
0
        public static async Task Main(string[] args)
        {
            var storeConnection = await Connect().ConfigureAwait(false);

            using var projectionsDispatcher = new ProjectionsDispatcher(storeConnection, new PositionStoreNullObject(), new IProjection[] { new ShowBalancesProjection() }, LoggerNullObject.Instance);
            projectionsDispatcher.Start();
            Console.ReadKey();
        }
예제 #2
0
        private static async Task Main(string[] args)
        {
            var container            = ConfigureIoc();
            var mediator             = container.GetInstance <IMediator>();
            var projectionConnection = await MakeNewEventStoreConnection().ConfigureAwait(false);

            var availableAccountsProjection = new AvailableAccountsProjection();

            using var projectionsDispatcher = new ProjectionsDispatcher(projectionConnection,
                                                                        new PositionStoreNullObject(),
                                                                        new IProjection[] { availableAccountsProjection },
                                                                        LoggerNullObject.Instance);
            projectionsDispatcher.Start();
            while (true)
            {
                try
                {
                    System.Console.Clear();
                    System.Console.WriteLine("(c) - Create new bank account");
                    System.Console.WriteLine("(d) - deposit money");
                    System.Console.WriteLine("(w) - withdraw money");
                    var consoleKeyInfo = System.Console.ReadKey();
                    switch (consoleKeyInfo.Key)
                    {
                    case ConsoleKey.C:
                        await CreateAccountAsync(mediator).ConfigureAwait(false);

                        break;

                    case ConsoleKey.D:
                        await Deposit(mediator, availableAccountsProjection);

                        break;

                    case ConsoleKey.W:
                        await Withdraw(mediator, availableAccountsProjection);

                        break;
                    }
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                    System.Console.WriteLine("Press any key to continue");
                    System.Console.ReadKey();
                }
            }
        }