Exemplo n.º 1
0
        static void Main()
        {
            var container = new SimpleDependencyInjector();

            SetupBus(container);
            SetupDomainCommandHandlers(container);

            //SetupInMemoryRepo(container);
            //SetupInMemoryESRepo(container);

            SetupRavenDbRegularRepo(container);
            ExecuteSampleCommands(container);

            var employee = container.Get <IEmployeeRepository>().Load("12345");

            Console.WriteLine($"Employee {employee.Id} - {employee.Name} salary is ${employee.Salary}");

            var employee2 = container.Get <IEmployeeRepository>().Load("54321");

            Console.WriteLine($"Employee {employee2.Id} - {employee2.Name} salary is ${employee2.Salary}");

            var es = container.Get <EmployeeEventStore>();

            foreach (var entry in es.TopEventSourceEmployees())
            {
                Console.WriteLine($"Number of events to {entry.EmployeeId} is {entry.NumberOfEvents}");
            }

            foreach (var entry in es.TopSalaries())
            {
                Console.WriteLine($"{entry.EmployeeId} -  {entry.FullName} (${entry.Salary})");
            }
        }
Exemplo n.º 2
0
        private static void SetupInMemoryESRepo(SimpleDependencyInjector container)
        {
            var esrepo = new InMemoryEmployeeEventSourceRepository();

            container.BindToConstant <IEmployeeRepository>(esrepo);
            container.BindToConstant(esrepo);
            container.Get <IBus>().RegisterHandler <InMemoryEmployeeEventSourceRepository>();
        }
Exemplo n.º 3
0
        private static void SetupRavenDbRegularRepo(SimpleDependencyInjector container)
        {
            container.BindToConstant <IEmployeeRepository>(
                new Payroll.Infrastructure.RavenDbEmployeeRepository.EmployeeRepository()
                );

            container.BindToConstant(new EmployeeEventStore());
            container.Get <IBus>().RegisterHandler <EmployeeEventStore>();
        }