public static void AsService()
        {
            //Bootstrap
            var settings = ConnectionSettings.Create()
                           .SetDefaultUserCredentials(new UserCredentials("admin", "changeit"))
                           .KeepReconnecting()
                           .KeepRetrying()
                           //.UseConsoleLogger()
                           .Build();
            var conn = EventStoreConnection.Create(settings, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));

            conn.ConnectAsync().Wait();

            var eventNamespace = "Registration.Blueprint.Events";
            var eventAssembly  = "Registration";

            var repo = new SimpleRepo(conn, eventNamespace, eventAssembly);

            var rm = new RoomsReader(() => conn, repo.Deserialize);

            MainBus = new SimpleBus();

            var roomSvc = new RoomSvc(repo);

            MainBus.Subscribe <AddRoom>(roomSvc);

            rm.Start();
            RoomReadModel = rm;
        }
Exemple #2
0
        public void addRoom_command_will_save()
        {
            var eventNamespace = "Registration.Blueprint.Events";
            var eventAssembly  = "Registration";
            var settings       = ConnectionSettings.Create()
                                 .SetDefaultUserCredentials(new UserCredentials("admin", "changeit"))
                                 .KeepReconnecting()
                                 .KeepRetrying()
                                 //.UseConsoleLogger()
                                 .Build();
            var conn = EventStoreConnection.Create(settings, IPEndPoint.Parse("127.0.0.1:1113"));

            conn.ConnectAsync().Wait();


            var repo    = new SimpleRepo(conn, eventNamespace, eventAssembly);
            var roomSvc = new RoomSvc(repo);
            var roomId  = Guid.NewGuid();

            roomSvc.Handle(new AddRoom(roomId, "12B", "2nd Floor", "King"));

            var room = repo.Load <Room>(roomId);

            Assert.Equal(roomId, ((IEventSource)room).Id);
        }
        static void Main(string[] args)
        {
            //Bootstrap
            var settings = ConnectionSettings.Create()
                           .SetDefaultUserCredentials(new UserCredentials("admin", "changeit"))
                           .KeepReconnecting()
                           .KeepRetrying()
                           //.UseConsoleLogger()
                           .Build();
            var conn = EventStoreConnection.Create(settings, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));

            conn.ConnectAsync().Wait();

            var eventNamespace = "Registration.Blueprint.Events";
            var eventAssembly  = "Registration";

            var repo = new SimpleRepo(conn, eventNamespace, eventAssembly);

            var roomRm = new RoomsReader(() => conn, repo.Deserialize);

            var mainBus = new SimpleBus();

            var roomSvc = new RoomSvc(repo);

            mainBus.Subscribe <AddRoom>(roomSvc);

            var view       = new ConsoleView();
            var controller = new Controller(view, mainBus);

            var database = new DataBase();

            var eventDispatch = new EventDispatcher(database);

            var app = new RegistrationApp();

            app.GenerateData(eventDispatch);

            // roomRm.Subscribe( model => view.HistorySummaries = model);

            roomRm.Start();

            controller.StartCommandLoop();

            Console.WriteLine("press enter to exit");
            Console.ReadLine();
        }