public static void ConfigureApp(RegistrationApp app, string eventNamespace, string eventAssembly) { 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 repo = new SimpleRepo(conn, eventNamespace, eventAssembly); var userRm = new RegisteredUsers(() => conn, repo.Deserialize); var mainBus = new SimpleBus(); var userSvc = new UserSvc(repo); mainBus.Subscribe <RegisterUser>(userSvc); mainBus.Subscribe <ChangeName>(userSvc); //application wire up //app.CommandPublisher = mainBus; //userRm.Subscribe(app.DisplayUsers); //start userRm.Start(); }
public void can_create_room_type() { var eventNamespace = "Administration.EventModel.Events"; var eventAssembly = "Administration"; 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 repo = new SimpleRepo(conn, eventNamespace, eventAssembly); var roomSvc = new AdminSvc(repo); var roomTypeId = Guid.NewGuid(); roomSvc.Handle(new AddRoomType(roomTypeId, "King", "big bed room")); var room = repo.Load <RoomType>(roomTypeId); Assert.Equal(roomTypeId, ((IEventSource)room).Id); }
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; }
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); }
public void Handle(ContactUpdatedEvent contactUpdatedEvent) { Contact contact = contactUpdatedEvent.Contact; using (var mgr = new SimpleRepo()) { if (contactUpdatedEvent.IsNew) { mgr.InsertContact(contact); } else { mgr.UpdateContact(contact); } } }
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(); }
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 = "Administration.EventModel.Events"; var eventAssembly = "Administration"; var repo = new SimpleRepo(conn, eventNamespace, eventAssembly); var roomTypeRm = new RoomTypeReader(() => conn, repo.Deserialize); var mainBus = new SimpleBus(); var adminSvc = new AdminSvc(repo); mainBus.Subscribe <AddRoomType>(adminSvc); mainBus.Subscribe <AddRoom>(adminSvc); var view = new ConsoleView(); var controller = new Controller(view, mainBus); roomTypeRm.Subscribe(model => view.RoomSummaries = model); view.Redraw(); roomTypeRm.Start(); controller.StartCommandLoop(); Console.WriteLine("press enter to exit"); Console.ReadLine(); }
void Awake() { // Initialize environment Universe.root = new Universe(); SimpleRepo repo = new SimpleRepo(); // Attributes trollFactor = new NormalizedAttribute( () => Random.Range(0, 1f) ); anger = new NormalizedAttribute(() => 0); repo.RegisterAttribute(trollFactor); repo.RegisterAttribute(anger); trollFactor.SetDebugLabel("Troll Factor"); anger.SetDebugLabel("Anger"); // Users User[] users = { new User("Julian"), new User("Andy"), new User("Mike") }; foreach (User user in users) { user.Repository = repo; } // Effects annoy = new Effect(); annoy.Modifiers.Add(new FloatModifier(anger, .2f)); repo.effects.Add(annoy); annoy.SetDebugLabel("Annoy"); incite = new Effect(); incite.Modifiers.Add(new FloatModifier(anger, .4f)); repo.effects.Add(incite); incite.SetDebugLabel("Anger"); calm = new Effect(); calm.Modifiers.Add(new FloatModifier(anger, -.1f)); repo.effects.Add(calm); calm.SetDebugLabel("Calm Down"); // Interactions start = new Interaction(0); flame = new Interaction(1); quit = new Interaction(0); repo.RegisterInteraction(start); repo.RegisterInteraction(flame); repo.RegisterInteraction(quit); start.SetDebugLabel("Start Thread"); flame.SetDebugLabel("Flame"); quit.SetDebugLabel("Ragequit"); // Attribution foreach (User user in users) { user.Subscribe(); Universe.root.entities.Add(user); } // Unity hooks ComponentManager hook = GetComponent <ComponentManager>(); hook.Hook("Universe.root", Universe.root); hook.Hook <SimpleRepoComponent>("simple-repo", repo); }