private static void RegisterCommands(Container container) { var eventDelegator = new EventBus(); var eventStore = new EventStore(eventDelegator); var aggregateFactory = new AggregateFactory(); var commandProcessor = new CommandProcessor(aggregateFactory, eventStore); container.RegisterSingleton<IProcessCommands>(() => commandProcessor); }
public static void Init() { var storeEvents = WireupEventStore(); var aggregateFactory = new AggregateFactory(); var conflictDetector = new ConflictDetector(); var eventRepository = new EventStoreRepository(storeEvents, aggregateFactory, conflictDetector); _commandHandlerService = new CommandHandlerService(); _commandHandlerService.InitHandlers(eventRepository); }
public AssembledComponents AssembleComponents() { var documents = CreateNuclear(new DocumentStrategy()); var streamer = Streamer; var tapes = Tapes; var streaming = Streaming; var routerQueue = CreateQueueWriter(Topology.RouterQueue); var aggregates = new AggregateFactory(tapes, streamer, routerQueue); var sender = new SimpleMessageSender(streamer, routerQueue); var flow = new MessageSender(sender); var builder = new CqrsEngineBuilder(streamer); var log = tapes.GetOrCreateStream(Topology.DomainLogName); var dispatcher = new SimpleDispatcher(aggregates, streamer, log); builder.Handle(CreateInbox(Topology.RouterQueue), Topology.Route(CreateQueueWriter, streamer, tapes), "router"); builder.Handle(CreateInbox(Topology.EntityQueue), aggregates.Dispatch); var functions = new RedirectToDynamicEvent(); // documents //functions.WireToWhen(new RegistrationUniquenessProjection(atomic.Factory.GetEntityWriter<unit, RegistrationUniquenessDocument>())); // UI projections var projectionStore = CreateNuclear(new ProjectionStrategy()); foreach (var projection in BootstrapProjections.BuildProjectionsWithWhenConvention(projectionStore.Factory)) { functions.WireToWhen(projection); } // processes //functions.WireToWhen(new Domain.RecipeProcess(flow)); builder.Handle(CreateInbox(Topology.EventsQueue), aem => CallHandlers(functions, aem)); var timer = new StreamingTimerService(CreateQueueWriter(Topology.RouterQueue), streaming.GetContainer(Topology.FutureMessagesContainer), streamer); builder.Handle(CreateInbox(Topology.TimerQueue), timer.PutMessage); builder.AddProcess(timer); // GNS: just for this simple sample. In reality one would have some command handlers involved Bus.SetBus(new SimpleBus(sender, dispatcher)); return new AssembledComponents { Builder = builder, Sender = sender, Dispatcher = dispatcher, ProjectionFactory = projectionStore.Factory, Setup = this }; }
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // Setup factory, delegator (bus) and store var aggregateFactory = new AggregateFactory(); var eventDelegator = new EventDelegator(); var eventStore = new EventStore(eventDelegator); // Create new commandprocessor and add it to IoC SetupCommandProcessor(services, eventStore, aggregateFactory); // Create new view for getAllReservations and add it to IoC SetupViews(services, eventDelegator); }
public void CanCreateNewAggregate() { // arrange var factory = AggregateFactory.For <Counter>(); var aggregateId = "some id"; // act var aggregate = factory.CreateNew(aggregateId); // assert Assert.NotNull(aggregate); Assert.AreEqual(aggregateId, aggregate.Id); Assert.AreEqual(0, aggregate.OriginalVersion); Assert.AreEqual(0, aggregate.Changes.Count()); Assert.NotNull(aggregate.State); Assert.AreEqual(0, aggregate.State.Version); }
public void ShouldAddProductToProductCatalog() { var rootId = Guid.NewGuid(); var queueService = new MemoryQueueService(); var appendOnly = new MemoryAppendOnlyStore(queueService); var eventStore = new EventStore(appendOnly); var factory = new AggregateFactory(eventStore); var rootToSave = factory.Create <ProductCatalogAggregate>(rootId); eventStore.AppendToStream <ProductCatalogAggregate>(rootToSave.Id, rootToSave.Version, rootToSave.Changes); var root = factory.Load <ProductCatalogAggregate>(rootId); root.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook", "Dell Inspiron 15000")); Assert.True(root.Changes.Count == 1); Assert.True(root.Changes.ElementAt(0).GetType() == typeof(ProductCreated)); }
public async Task <T> Get <T>(Guid aggregateId, CancellationToken cancellationToken = default(CancellationToken)) where T : AggregateRoot { var aggregate = AggregateFactory <T> .CreateAggregate(); var snapshotVersion = await TryRestoreAggregateFromSnapshot(aggregateId, aggregate, cancellationToken).ConfigureAwait(false); if (snapshotVersion == -1) { return(await _repository.Get <T>(aggregateId, cancellationToken).ConfigureAwait(false)); } var events = (await _eventStore.Get(aggregateId, snapshotVersion, cancellationToken).ConfigureAwait(false)) .Where(desc => desc.Version > snapshotVersion); aggregate.LoadFromHistory(events); return(aggregate); }
public void RetrieveAggregateLoadedFromSnapshot() { var rootId = Guid.NewGuid(); var resolver = new MemoryResolver(); var eventBus = new MemoryEventBus(resolver); var appendOnly = new MemoryAppendOnlyStore(eventBus); var eventStore = new EventStore(appendOnly, eventBus); var snapShotRepo = new SnapshotRepository(); var factory = new AggregateFactory(eventStore, snapShotRepo); var view = new ProductView(); resolver.Register <ProductCreated>(view); var productAggregate = factory.Create <ProductCatalogAggregate>(rootId); productAggregate.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook Acer Aspire 3", "Notebook Acer Aspire 3 A315-53-348W Intel Core i3-6006U RAM de 4GB HD de 1TB Tela de 15.6” HD Windows 10")); productAggregate.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook Asus Vivobook", "Notebook Asus Vivobook X441B-CBA6A de 14 Con AMD A6-9225/4GB Ram/500GB HD/W10")); productAggregate.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook 2 em 1 Dell", "Notebook 2 em 1 Dell Inspiron i14-5481-M11F 8ª Geração Intel Core i3 4GB 128GB SSD 14' Touch Windows 10 Office 365 McAfe")); productAggregate.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook Gamer Dell", "Notebook Gamer Dell G3-3590-M60P 9ª Geração Intel Core i7 8GB 512GB SSD Placa Vídeo NVIDIA 1660Ti 15.6' Windows 10")); productAggregate.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook Lenovo 2 em 1 ideapad C340", "Notebook Lenovo 2 em 1 ideapad C340 i7-8565U 8GB 256GB SSD Win10 14' FHD IPS - 81RL0001BR")); eventStore.AppendToStream <ProductCatalogAggregate>(productAggregate.Id, productAggregate.Version, productAggregate.Changes, productAggregate.DomainEvents.ToArray()); var stream = eventStore.LoadEventStream(rootId); snapShotRepo.SaveSnapshot(rootId, productAggregate, stream.Version); var aggregateReloadedFromSnapshot = factory.Load <ProductCatalogAggregate>(rootId); ProductCatalogAggregate root; long snapshotVersion = 0; var snap = snapShotRepo.TryGetSnapshotById(rootId, out root, out snapshotVersion); stream = eventStore.LoadEventStreamAfterVersion(rootId, snapshotVersion); Assert.True(snap); Assert.True(root != null); Assert.True(snapshotVersion == 6); Assert.True(stream.Events.Count == 0); Assert.True(aggregateReloadedFromSnapshot.Changes.Count == 0); Assert.True(aggregateReloadedFromSnapshot.Id == rootId); Assert.True(view.Products.Count == 5); }
public void Setup() { var eventStore = new TestInMemoryEventStore(); var eventPublisher = new TestEventPublisher(); _snapshotStore = new TestSnapshotStore(); var snapshotStrategy = new DefaultSnapshotStrategy <ISingleSignOnToken>(); var aggregateFactory = new AggregateFactory(null); var repository = new SnapshotRepository <ISingleSignOnToken>(_snapshotStore, snapshotStrategy, new Repository <ISingleSignOnToken>(aggregateFactory, eventStore, eventPublisher, new NullCorrelationIdHelper()), eventStore, aggregateFactory); var session = new UnitOfWork <ISingleSignOnToken>(repository); var aggregate = new TestSnapshotAggregate(); for (int i = 0; i < 30; i++) { aggregate.DoSomething(); } session.Add(aggregate); session.Commit(); }
protected override TAggregateRoot LoadAggregate <TAggregateRoot>(Guid id, IList <IEvent <TAuthenticationToken> > events = null) { var aggregate = AggregateFactory.CreateAggregate <TAggregateRoot>(); /* * IList<IEvent<TAuthenticationToken>> theseEvents = events ?? EventStore.Get<TAggregateRoot>(id).ToList(); * if (!theseEvents.Any()) * throw new AggregateNotFoundException<TAggregateRoot, TAuthenticationToken>(id); * * var duplicatedEvents = * theseEvents.GroupBy(x => x.Version) * .Select(x => new { Version = x.Key, Total = x.Count() }) * .FirstOrDefault(x => x.Total > 1); * if (duplicatedEvents != null) * throw new DuplicateEventException<TAggregateRoot, TAuthenticationToken>(id, duplicatedEvents.Version); * * aggregate.LoadFromHistory(theseEvents); */ return(aggregate); }
public void creates_Aggregate_by_Applying_events1() { //---------Load & Replay Envents var events = new List <DomainEvent> { new UserRegistered(1, "Admin", "John", "Doe"), new UserActivated(1), // new UserPersonalInfoUpdated("Jack","Doe"), }; var ddd = Builder <UserPersonalInfoUpdated> .CreateListOfSize(1000); var factory = new AggregateFactory(); var user = factory.Create <User>(events); user.IsActive.Should().BeTrue(); user.FirstName.Should().Be("Jack"); user.LastName.Should().Be("Doe"); }
public void Setup() { IEventStore <ISingleSignOnToken> eventStore = new TestInMemoryEventStore(); var eventPublisher = new TestEventPublisher(); _snapshotStore = new TestInMemorySnapshotStore(); var snapshotStrategy = new DefaultSnapshotStrategy <ISingleSignOnToken>(); var aggregateFactory = new AggregateFactory(new TestDependencyResolver()); var repository = new SnapshotRepository <ISingleSignOnToken>(_snapshotStore, snapshotStrategy, new Repository <ISingleSignOnToken>(aggregateFactory, eventStore, eventPublisher, new NullCorrelationIdHelper()), eventStore, aggregateFactory); _unitOfWork = new UnitOfWork <ISingleSignOnToken>(repository); _aggregate = new TestSnapshotAggregate(); for (var i = 0; i < 20; i++) { _unitOfWork.Add(_aggregate); _aggregate.DoSomething(); _unitOfWork.Commit(); } }
public void ShouldIncreaseVersionCorrectly() { var eventBus = new MemoryEventBus(new MemoryResolver()); var appendOnly = new MemoryAppendOnlyStore(eventBus); var eventStore = new EventStore(appendOnly, eventBus); var rootId = Guid.NewGuid(); var factory = new AggregateFactory(eventStore); var root = factory.Create <ProductCatalogAggregate>(rootId); eventStore.AppendToStream <ProductCatalogAggregate>(root.Id, root.Version, root.Changes, root.DomainEvents.ToArray()); root = factory.Load <ProductCatalogAggregate>(rootId); root.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook", "Dell Inspiron 15000")); root.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook Asus Vivobook", "Notebook Asus Vivobook X441B-CBA6A de 14 Con AMD A6-9225/4GB Ram/500GB HD/W10")); root.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook 2 em 1 Dell", "Notebook 2 em 1 Dell Inspiron i14-5481-M11F 8ª Geração Intel Core i3 4GB 128GB SSD 14' Touch Windows 10 Office 365 McAfe")); eventStore.AppendToStream <ProductCatalogAggregate>(root.Id, root.Version, root.Changes, root.DomainEvents.ToArray()); root = factory.Load <ProductCatalogAggregate>(rootId); Assert.True(4 == root.Version); }
public void When_adding_new_item() { var aggregate = AggregateFactory.BuildEmpty <Order>(); aggregate.ApplyEvents(new OrderCreated(aggregate.Id, 1, Guid.NewGuid()), new ItemAdded(aggregate.Id, Guid.NewGuid(), 2, new Money(100), 1)); var initialSum = aggregate.TotalPrice; var initialItemsCount = aggregate.Items.Count; var itemAddedEventB = aggregate.ApplyEvent(new ItemAdded(aggregate.Id, Guid.NewGuid(), 1, new Money(50), 2)); //Order_items_contains_new_one_as_separate_item() Assert.NotEmpty(aggregate.Items.Where(i => i.Quantity == itemAddedEventB.Quantity && i.Sku == itemAddedEventB.Sku && i.TotalPrice == itemAddedEventB.TotalPrice)); //Order_items_count_is_increased_by_one() Assert.Equal(initialItemsCount + 1, aggregate.Items.Count); //Order_total_sum_is_increased_by_new_item_total() Assert.Equal(itemAddedEventB.TotalPrice, aggregate.TotalPrice - initialSum); }
public static Auction CreateTestAuction(decimal?minPrice = null, Window window = null) { var auction = new Auction("test-auction-id", new AuctionState()); var price = minPrice ?? 10; window = window ?? new Window { Start = DateTime.UtcNow.AddDays(-1), End = DateTime.UtcNow.AddDays(1) }; auction.Create( "test-seller-id", new Item { Id = "test-item-id", Name = "item name" }, price, window); // create a new aggregate from the state, to ensure the aggregate doesn't come with changes return(AggregateFactory.For <Auction>().CreateFromState(auction.Id, auction.State)); }
public void Run() { var eventstorage = new SpecEventStorage(Given().ToList()); var snapshotstorage = new SpecSnapShotStorage(Snapshot); var eventpublisher = new SpecEventPublisher(); var aggregateFactory = new AggregateFactory(null, new ConsoleLogger(new LoggerSettings(), new CorrelationIdHelper(new ThreadedContextItemCollectionFactory()))); var snapshotStrategy = new DefaultSnapshotStrategy <ISingleSignOnToken>(); var repository = new SnapshotRepository <ISingleSignOnToken>(snapshotstorage, snapshotStrategy, new AggregateRepository <ISingleSignOnToken>(aggregateFactory, eventstorage, eventpublisher, new NullCorrelationIdHelper(), new ConfigurationManager()), eventstorage, aggregateFactory); UnitOfWork = new UnitOfWork <ISingleSignOnToken>(repository); Aggregate = UnitOfWork.Get <TAggregate>(Guid.Empty); var handler = BuildHandler(); handler.Handle(When()); Snapshot = snapshotstorage.Snapshot; PublishedEvents = eventpublisher.PublishedEvents; EventDescriptors = eventstorage.Events; }
public void ShouldMergeEvents() { var eventBus = new MemoryEventBus(new MemoryResolver()); var appendOnly = new MemoryAppendOnlyStore(eventBus); var eventStore = new EventStore(appendOnly, eventBus); var snapShotRepo = new SnapshotRepository(); var factory = new AggregateFactory(eventStore, snapShotRepo); var rootId = Guid.NewGuid(); var handler = new ProductServiceCommandHandler(eventStore, factory); handler.Execute(new CreateProductCatalog(rootId)); var prodId = Guid.NewGuid(); handler.Execute(new CreateProductCommand(rootId, prodId, "Notebook Lenovo 2 em 1 ideapad C340", "Notebook Lenovo 2 em 1 ideapad C340 i7-8565U 8GB 256GB SSD Win10 14' FHD IPS - 81RL0001BR")); var threads = new List <Task>(); threads.Add(Task.Run(() => { var handlerThread1 = new ProductServiceCommandHandler(eventStore, factory); handlerThread1.Execute(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook 2 em 1 Dell", "Notebook 2 em 1 Dell Inspiron i14-5481-M11F 8ª Geração Intel Core i3 4GB 128GB SSD 14' Touch Windows 10 Office 365 McAfe")); })); threads.Add(Task.Run(() => { var handlerThread2 = new ProductServiceCommandHandler(eventStore, factory); handlerThread2.Execute(new ChangeProductNameCommand(rootId, prodId, "Novo nome")); })); Task.WaitAll(threads.ToArray()); var stream = eventStore.LoadEventStream(rootId); var productChanged = (ProductNameChanged)stream.Events.Where(x => x.GetType() == typeof(ProductNameChanged)).FirstOrDefault(); Assert.True(4 == stream.Version); Assert.True("Novo nome" == productChanged.Name); }
public void Given_instance_saga_When_recovering_from_creation() { var aggregateFactory = new AggregateFactory(); var sagaId = Guid.NewGuid(); _data = aggregateFactory.Build <SagaDataAggregate <SoftwareProgrammingSagaData> >(sagaId); var saga = new SoftwareProgrammingSaga(); var initialState = new SoftwareProgrammingSagaData(saga.MakingCoffee.Name); var eventsToReplay = new DomainEvent[] { new SagaCreatedEvent <SoftwareProgrammingSagaData>(initialState, sagaId) }; _data.ApplyEvents(eventsToReplay); _sagaInstance = SagaInstance.New(saga, _data); //Try to transit saga by message, available only in desired state _coffeMakeFailedEvent = new CoffeMakeFailedEvent(Guid.NewGuid(), Guid.NewGuid()); _sagaInstance.Transit(_coffeMakeFailedEvent); _dispatchedCommands = _sagaInstance.CommandsToDispatch; }
public void ShouldIncrementVersionCorrectly() { var rootId = Guid.NewGuid(); var queueService = new MemoryQueueService(); var appendOnly = new MemoryAppendOnlyStore(queueService); var eventStore = new EventStore(appendOnly); var factory = new AggregateFactory(eventStore); var rootToSave = factory.Create <ProductCatalogAggregate>(rootId); eventStore.AppendToStream <ProductCatalogAggregate>(rootToSave.Id, rootToSave.Version, rootToSave.Changes); var stream = eventStore.LoadEventStream(rootId); var root = new ProductCatalogAggregate(stream); root.CreateProduct(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook", "Dell Inspiron 15000")); eventStore.AppendToStream <ProductCatalogAggregate>(root.Id, root.Version, root.Changes); stream = eventStore.LoadEventStream(rootId); root = new ProductCatalogAggregate(stream); Assert.Equal(2, stream.Version); Assert.Equal(1, root.CountProducts()); }
public void CannotCreateFromUnknownEvents() { // arrange var factory = AggregateFactory.For <Counter>(); var aggregateId = "some id"; var events = new IAggregateEvent[] { new AggregateEvent <CounterIncremented>(aggregateId, 1, DateTime.UtcNow, new CounterIncremented { Increment = 1 }), new AggregateEvent <EventThatNoAggregateKnows>(aggregateId, 2, DateTime.UtcNow, new EventThatNoAggregateKnows()), }; // act and assert try { // TODO: should throw a specific known exception for this scenario factory.CreateFromEvents(aggregateId, events); Assert.Fail("should not have been possible to create the aggregate using an unknown event"); } catch (Exception) { Assert.Pass(); } }
public async Task Can_Partially_Update_Product_Variants() { AggregateFactory.Configure(); var repository = new ProductRepository(new AggregateFactory()); //Create a product var product = new ProductDTO(); product.Id = Guid.NewGuid().ToString(); //Create a variant var variant1 = new ProductDTO(); variant1.Id = "1"; variant1.Title = "my title 1"; variant1.Details.CustomField1 = "a string value"; variant1.Details.CustomField2 = 42; //Create another variant var variant2 = new ProductDTO(); variant2.Id = "2"; variant2.Title = "my title 2"; product.Variants = new List <Product> { variant1, variant2 }; Console.WriteLine("Indexing as " + product.Id); await repository.IndexAsync(product); await Task.Delay(500); //Create a 'copy' of the product, and reindex with just the second variant //Should update the second variant, but leave the first untouched var newProduct = new ProductDTO(); newProduct.Id = product.Id; variant2.Title = "my new title 2"; newProduct.Variants = new List <Product> { variant2 }; Console.WriteLine("Reindexing as " + product.Id); //TODO: Make this method work as expected await repository.IndexAsync(newProduct); var finalProduct = await repository.GetVariantsAsync(product.Id); throw new NotImplementedException(); }
protected TAggregate CreateNewAggregate(IIdentity identity) { var aggregate = (TAggregate)AggregateFactory.Build(typeof(TAggregate), identity, null); SetupContext(aggregate); return aggregate; }
private static void InitGetEventStore(IApplicationSettings applicationSettings) { var endpoint = GetEventStoreEndpoint(applicationSettings); var connection = EventStoreConnection.Create(endpoint); connection.ConnectAsync().Wait(); var factory = new AggregateFactory(); _repository = new GesRepository(connection, factory); }
public ProductServiceCommandHandler(IEventStore <Guid> eventStore, AggregateFactory factory) : base(eventStore) { _eventStore = eventStore; _factory = factory; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); MatchingPuzzleComponent = new MatchingPuzzleComponent(); pI = new PlayerInfo(); Quests = new List <Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
public void CanCreateFactory() { Assert.DoesNotThrow(() => AggregateFactory.For <Race>()); }
static void Main(string[] args) { const string integrationPath = @"temp"; ConfigureObserver(); var config = FileStorage.CreateConfig(integrationPath, "files"); var demoMessages = new List <ISampleMessage>(); var currentProcess = Process.GetCurrentProcess(); demoMessages.Add(new InstanceStarted("Inject git rev", currentProcess.ProcessName, currentProcess.Id.ToString())); { // wipe all folders config.Reset(); Console.WriteLine("Starting in funny mode"); var security = new SecurityId(0); demoMessages.Add(new CreateSecurityAggregate(security)); demoMessages.Add(new AddSecurityPassword(security, "Rinat Abdullin", "*****@*****.**", "password")); demoMessages.Add(new AddSecurityIdentity(security, "Rinat's Open ID", "http://abdullin.myopenid.org")); demoMessages.Add(new AddSecurityKey(security, "some key")); } var atomic = config.CreateNuclear(new DocumentStrategy()); var identity = new IdentityGenerator(atomic); var streamer = Contracts.CreateStreamer(); var tapes = config.CreateTape(Topology.TapesContainer); var streaming = config.CreateStreaming(); var routerQueue = config.CreateQueueWriter(Topology.RouterQueue); var aggregates = new AggregateFactory(tapes, streamer, routerQueue, atomic, identity); var sender = new SimpleMessageSender(streamer, routerQueue); var flow = new MessageSender(sender); var builder = new CqrsEngineBuilder(streamer); builder.Handle(config.CreateInbox(Topology.RouterQueue), Topology.Route(config.CreateQueueWriter, streamer, tapes), "router"); builder.Handle(config.CreateInbox(Topology.EntityQueue), aggregates.Dispatch); var functions = new RedirectToDynamicEvent(); // documents //functions.WireToWhen(new RegistrationUniquenessProjection(atomic.Factory.GetEntityWriter<unit, RegistrationUniquenessDocument>())); // UI projections var projectionStore = config.CreateNuclear(new ProjectionStrategy()); foreach (var projection in BootstrapProjections.BuildProjectionsWithWhenConvention(projectionStore.Factory)) { functions.WireToWhen(projection); } // processes //functions.WireToWhen(new BillingProcess(flow)); //functions.WireToWhen(new RegistrationProcess(flow)); functions.WireToWhen(new ReplicationProcess(flow)); builder.Handle(config.CreateInbox(Topology.EventsQueue), aem => CallHandlers(functions, aem)); var timer = new StreamingTimerService(config.CreateQueueWriter(Topology.RouterQueue), streaming.GetContainer(Topology.FutureMessagesContainer), streamer); builder.Handle(config.CreateInbox(Topology.TimerQueue), timer.PutMessage); builder.AddProcess(timer); using (var cts = new CancellationTokenSource()) using (var engine = builder.Build()) { var task = engine.Start(cts.Token); foreach (var sampleMessage in demoMessages) { sender.SendOne(sampleMessage); } Console.WriteLine(@"Press enter to stop"); Console.ReadLine(); cts.Cancel(); if (task.Wait(5000)) { Console.WriteLine(@"Terminating"); } } }
protected override TAggregateRoot CreateAggregate <TAggregateRoot>(Guid id) { var aggregate = AggregateFactory.CreateAggregate <TAggregateRoot>(); return(aggregate); }
public BuySubscriptionSagaFactory(AggregateFactory aggregateFactory) { _aggregateFactory = aggregateFactory; }
public Account_hydration_tests() { Account = AggregateFactory.BuildEmpty <Account>(); _created = Account.ApplyEvent(new Fixture().Create <AccountCreated>()); _initialAmountEvent = Account.ApplyEvent(new AccountReplenish(_created.SourceId, Guid.NewGuid(), new Money(100))); }
public SimpleDispatcher(AggregateFactory aggregateFactory, IEnvelopeStreamer serializer, ITapeStream tapeStream) { _aggregateFactory = aggregateFactory; _serializer = serializer; _tapeStream = tapeStream; }
private static void SetupCommandProcessor(IServiceCollection services, EventStore eventStore, AggregateFactory aggregateFactory) { var commandProcessor = new CommandProcessor(eventStore, aggregateFactory); services.AddSingleton<IProcessCommands>(provider => commandProcessor); }