public static void Run()
 {
     InitializeItems()
     .ContinueWith(_ => ReadItems())
     .ContinueWith(_ => DevelopmentSiloHost.WaitForInteraction())
     .Wait();
 }
 public static void Run()
 {
     SetupCatalog()
     .ContinueWith(_ => ReadCatalog())
     .ContinueWith(_ => DevelopmentSiloHost.WaitForInteraction())
     .Wait();
 }
        private static void PrintBalance(BankAccountStateMachineBalance balance)
        {
            Console.WriteLine(balance.Match(() => "Zero Balance",
                                            _ => $"Active Balance: {_.Value}",
                                            _ => $"Overdrawn Balance: {_.Value}"));

            DevelopmentSiloHost.WaitForInteraction();
        }
        private static async Task ShowAccountState(IBankAccountGrain accountGrain)
        {
            var bankAccountState = await accountGrain.GetState();

            var history = await accountGrain.GetEvents();

            Console.WriteLine(bankAccountState.Balance);
            foreach (var item in history)
            {
                Console.WriteLine(item);
            }

            DevelopmentSiloHost.WaitForInteraction();
        }
        public static async Task Run()
        {
            var accountAggregateGrain =
                GrainClient.GrainFactory.GetGrain <IBankAccountAggregateGrain>(Constants.BankAccountAggregateGrainId);
            var accountGrains =
                Constants.BankAccountGrainIds.Select(id => GrainClient.GrainFactory.GetGrain <IBankAccountGrain>(id))
                .ToList();

            // register the account grains with the aggregate
            foreach (var accountGrain in accountGrains)
            {
                await accountAggregateGrain.RegisterGrain(accountGrain);
            }

            // run a set of operations...
            foreach (var accountGrain in accountGrains.Take(10))
            {
                await accountGrain.CreditAmount(100.0M);
            }

            //...and see the aggregate value updated consequently
            var totalBalance = await accountAggregateGrain.GetAggregateValue();

            Console.WriteLine($"Total Balance (should be 10 * 100) {totalBalance.Value.Balance}");

            // run another set of operations...
            foreach (var accountGrain in accountGrains.Take(10))
            {
                await accountGrain.CreditAmount(100.0M);
            }

            // ...and see the aggregate value accumulate
            totalBalance = await accountAggregateGrain.GetAggregateValue();

            Console.WriteLine($"Total Balance (should be 10 * 100 * 2) {totalBalance.Value.Balance}");

            DevelopmentSiloHost.WaitForInteraction();
        }