예제 #1
0
        static void Main(string[] args)
        {
            var runtime = new SampleRunTime();

            runtime.Start();

            var fakeAccountTable = new FakeAccountTable();

            runtime.ServiceLocator.Register(fakeAccountTable);
            runtime.ServiceLocator.Register(new AccountReportReadService(fakeAccountTable));
            var commandBus = runtime.ServiceLocator.Resolve <ICommandBus>();

            var cmd = new CreateAccountCommand {
                FirstName = "Ali", LastName = "Kh"
            };

            commandBus.Send(cmd);

            var accountReportReadModel = runtime.ServiceLocator.Resolve <AccountReportReadService>();

            Console.WriteLine("Accounts in database");
            Console.WriteLine("####################");
            foreach (var account in accountReportReadModel.GetAccounts())
            {
                Console.WriteLine("Id: {0} Name: {1}", account.Id, account.Name);
            }

            runtime.Shutdown();

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var runtime = SampleRunTime.Instance;

            runtime.Start();

            // Infrastructure and fakes
            var fakeAccountTable = new FakeAccountTable();

            runtime.ServiceLocator.Register(fakeAccountTable); // Create Fake-db
            runtime.ServiceLocator.Register(new AccountReportReadService(fakeAccountTable));
            var commandBus = runtime.CommandBus;


            // Create and send a couple of command
            var cmdMarcus = new CreateAccountCommand {
                FirstName = "Marcus", LastName = "Hammarberg"
            };
            var cmdDarren = new CreateAccountCommand {
                FirstName = "Darren", LastName = "Cauthon"
            };
            var cmdTyrone = new CreateAccountCommand {
                FirstName = "Tyrone", LastName = "Groves"
            };
            var cmdAdnan = new CreateAccountCommand {
                FirstName = "Adnan", LastName = "Asotic"
            };

            commandBus.Send(cmdMarcus);
            commandBus.Send(cmdDarren);
            commandBus.Send(cmdTyrone);
            commandBus.Send(cmdAdnan);

            // Get the denormalized version of the data back from the read model
            var accountReportReadModel = runtime.ServiceLocator.Resolve <AccountReportReadService>();

            Console.WriteLine("Accounts in database");
            Console.WriteLine("####################");
            foreach (var account in accountReportReadModel.GetAccounts())
            {
                Console.WriteLine(" Id: {0} Name: {1}", account.Id, account.Name);
            }



            runtime.Shutdown();

            Console.ReadLine();
        }
예제 #3
0
        static void Main(string[] args)
        {

            var runtime = new SampleRunTime();

            runtime.Start();

            // Infrastructure and fakes
            var fakeAccountTable = new FakeAccountTable();
            runtime.ServiceLocator.Register(fakeAccountTable); // Create Fake-db
            runtime.ServiceLocator.Register(new AccountReportReadService(fakeAccountTable));
            var commandBus = runtime.ServiceLocator.Resolve<ICommandBus>();


            // Create and send a couple of command
            var cmdMarcus = new CreateAccountCommand { FirstName = "Marcus", LastName = "Hammarberg" };
            var cmdDarren = new CreateAccountCommand { FirstName = "Darren", LastName = "Cauthon" };
            var cmdTyrone = new CreateAccountCommand { FirstName = "Tyrone", LastName = "Groves" };
            commandBus.Send(cmdMarcus);
            commandBus.Send(cmdDarren);
            commandBus.Send(cmdTyrone);

            // Get the denormalized version of the data back from the read model
            var accountReportReadModel = runtime.ServiceLocator.Resolve<AccountReportReadService>();
            Console.WriteLine("Accounts in database");
            Console.WriteLine("####################");
            foreach (var account in accountReportReadModel.GetAccounts())
            {
                Console.WriteLine(" Id: {0} Name: {1}", account.Id, account.Name);
            }



            runtime.Shutdown();

            Console.ReadLine();
        }
 public AccountReportReadService(FakeAccountTable fakeAccountDb)
 {
     this.fakeAccountDb = fakeAccountDb;
 }
 public AccountReportReadService(FakeAccountTable fakeAccountDb)
 {
     this.fakeAccountDb = fakeAccountDb;
 }
예제 #6
0
 public AccountEventHandler(FakeAccountTable accountTable)
 {
     this.accountTable = accountTable;
 }
 public AccountReportDenormalizer(FakeAccountTable accountTable)
 {
     this.accountTable = accountTable;
 }