protected override void Load(ContainerBuilder builder)
        {
            // The generic ILogger<TCategoryName> service was added to the ServiceCollection by ASP.NET Core.
            // It was then registered with Autofac using the Populate method in ConfigureServices.
            builder.RegisterType <SerilogLogger>().As <ILog>();
            builder.RegisterType <ExceptionHandlingMiddleware>();
            builder.RegisterType <MongoDatabaseFactory>().As <IMongoDatabaseFactory>();
            builder.RegisterType <AppointmentService>().As <IAppointmentService>();
            builder.RegisterType <InMemoryEventBusSubscriptionsManager>().As <IEventBusSubscriptionsManager>();
            builder.RegisterType <IntegrationTestEventHandler>().As <IIntegrationEventHandler>();
            // builder.RegisterType<SagaUpdater<AppointmentAggregate, AppointmentId, AppointmentBookedEvent, AppointmentSaga>>().As<ISagaUpdater<AppointmentAggregate, AppointmentId, AppointmentBookedEvent, AppointmentSaga>>();
            builder.RegisterType <OrdersApplicationService>().As <IOrdersApplicationService>();
            builder.RegisterType <PaymentsApplicationService>().As <IPaymentsApplicationService>();
            builder.RegisterType <PaymentProviderFactory>().As <IPaymentProviderFactory>();
            builder.RegisterType <Payments.Domain.Payments.Providers.ConfigurationProvider>().As <Payments.Domain.Payments.Providers.IConfigurationProvider>();
            builder.RegisterType <TestProvider1PaymentProvider>().As <IPaymentProvider>();
            builder.RegisterType <ReadModelFactory <AppointmentReadModel> >().As <IReadModelFactory <AppointmentReadModel> >();
            builder.RegisterType <ReadModelFactory <AppointmentInsertReadModel> >().As <IReadModelFactory <AppointmentInsertReadModel> >();
            builder.RegisterType <AggregateReadStoreManager <AppointmentAggregate, AppointmentId, MongoDbReadModelStore <AppointmentReadModel>, AppointmentReadModel> >();
            ISnapshotStrategy newStrategy = SnapshotEveryFewVersionsStrategy.With(10);

            builder.RegisterInstance(newStrategy);
            // builder.RegisterType<EventFlowOptionsSnapshotExtensions>
            builder.Populate(new ServiceCollection());

            KafkaServicesRegistration.Register(builder);
        }
        public TransactionAggregate(TransactionId id, IScopedContext scopedContext)
            : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
        {
            _scopedContext = scopedContext;

            Register<TransactionAddedEvent>(e => _transactionsReceived.Add(e.Transaction));
        }
Exemple #3
0
 public ThingyAggregate(ThingyId id)
     : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
     Register <ThingyPingEvent>(e => _pingsReceived.Add(e.PingId));
     Register <ThingyMessageAddedEvent>(e => _messages.Add(e.ThingyMessage));
     Register <ThingySagaStartRequestedEvent>(e => { /* do nothing */ });
     Register <ThingySagaCompleteRequestedEvent>(e => { /* do nothing */ });
 }
        public EmployeeAggregate(EmployeeId id, IScopedContext scopedContext)
            : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
        {
            _scopedContext = scopedContext;

            Register <EmployeeAddedEvent>(e => _records.Add(e.EmployeeRecord));
            Register <EmployeeSagaStartRequestedEvent>(e => { /* do nothing */ });
            Register <EmployeeSagaCompleteRequestedEvent>(e => { /* do nothing */ });
            Register <EmployeeDeletedEvent>(e => { /* do nothing */ });
        }
 public AccountAggregate(AccountId accountId) : base(accountId, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
     Register <AccountCreatedEvent>(Apply);
     Register <DailyWireTransferSetEvent>(Apply);
     Register <OverDraftLimitSetEvent>(Apply);
     Register <CashWithdrawnEvent>(Apply);
     Register <CashDepositedEvent>(Apply);
     Register <CheckDepositedEvent>(Apply);
     Register <AccountBlockedEvent>(Apply);
     Register <AccountUnblockedEvent>(Apply);
 }
 public ThingyAggregate(ThingyId id, IScopedContext scopedContext)
     : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
     _scopedContext = scopedContext;
     Register <ThingyPingEvent>(e => _pingsReceived.Add(e.PingId));
     Register <ThingyMessageAddedEvent>(e => _messages.Add(e.ThingyMessage));
     Register <ThingyMessageHistoryAddedEvent>(e => _messages.AddRange(e.ThingyMessages));
     Register <ThingySagaStartRequestedEvent>(e => { /* do nothing */ });
     Register <ThingySagaCompleteRequestedEvent>(e => { /* do nothing */ });
     Register <ThingyDeletedEvent>(e => { /* do nothing */ });
 }
Exemple #7
0
 public void CreateSnapshotTest(int amount)
 {
     using (var resolver = New
                           .AddEvents(typeof(CompetitionRegisteredEvent), typeof(CompetitionDeletedEvent), typeof(EntryRecordedEvent), typeof(EntryTimeCorrectedEvent))
                           .AddCommands(typeof(RegisterCompetitionCommand), typeof(DeleteCompetitionCommand), typeof(RecordEntryCommand), typeof(CorrectEntryTimeCommand))
                           .AddCommandHandlers(typeof(RegisterCompetitionHandler), typeof(DeleteCompetitionHandler), typeof(RecordEntryHandler), typeof(CorrectEntryTimeHandler))
                           .AddSnapshots(typeof(CompetitionSnapshot))
                           .RegisterServices(sr => sr.Register(i => SnapshotEveryFewVersionsStrategy.With(1)))
                           .CreateResolver())
     {
         RegisterCompetitionWithEntries(resolver, amount);
     }
 }
        public void CreateSnapshotTest(params string[] names)
        {
            using (var resolver = EventFlowOptions.New
                                  .AddEvents(typeof(CompetitionRegisteredEvent), typeof(CompetitionCorrectedEvent))
                                  .AddCommands(typeof(RegisterCompetitionCommand), typeof(CorrectCompetitionCommand))
                                  .AddCommandHandlers(typeof(RegisterCompetitionHandler), typeof(CorrectCompetitionHandler))
                                  .AddSnapshots(typeof(CompetitionSnapshot))
                                  .RegisterServices(sr => sr.Register(i => SnapshotEveryFewVersionsStrategy.With(1)))
                                  .UseInMemoryReadStoreFor <CompetitionReadModel>()
                                  .CreateResolver())
            {
                // Create a new identity for our aggregate root
                var domainId = CompetitionId.New;

                // Define some important value
                const string user  = "******";
                const string name1 = "test-competition";

                // Resolve the command bus and use it to publish a command
                var commandBus = resolver.Resolve <ICommandBus>();

                // Create
                var executionResult = commandBus.Publish(new RegisterCompetitionCommand(domainId, user, name1), CancellationToken.None);
                executionResult.IsSuccess.Should().BeTrue();

                // Resolve the query handler and use the built-in query for fetching
                // read models by identity to get our read model representing the
                // state of our aggregate root
                var queryProcessor = resolver.Resolve <IQueryProcessor>();
                var readModel      = queryProcessor.Process(new ReadModelByIdQuery <CompetitionReadModel>(domainId), CancellationToken.None);

                // Verify that the read model has the expected values
                readModel.Should().NotBeNull();
                readModel.AggregateId.Should().Be(domainId.Value);
                readModel.Competitionname.Should().Be(name1);

                foreach (string name2 in names)
                {
                    // Rename
                    executionResult = commandBus.Publish(new CorrectCompetitionCommand(domainId, name2), CancellationToken.None);
                    executionResult.IsSuccess.Should().BeTrue();

                    readModel = queryProcessor.Process(new ReadModelByIdQuery <CompetitionReadModel>(domainId), CancellationToken.None);

                    // Verify that the read model has the expected values
                    readModel.AggregateId.Should().Be(domainId.Value);
                    readModel.Competitionname.Should().Be(name2);
                }
            }
        }
        public EmployeeAggregate(EmployeeId id, IScopedContext scopedContext)
            : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
        {
            _scopedContext = scopedContext;

            Register <EmployeeAddedEvent>(e => _records.Add(e.EmployeeRecord));
            Register <EmployeeUpdatedEvent>(e => {
                var obj = _records.FirstOrDefault(x => x.Id == e.EmployeeRecord.Id);
                if (obj != null)
                {
                    obj.FullName   = e.EmployeeRecord.FullName;
                    obj.Department = e.EmployeeRecord.Department;
                }
            });
            //Register<EmployeeSagaStartRequestedEvent>(e => {/* do nothing */});
            //Register<EmployeeSagaCompleteRequestedEvent>(e => {/* do nothing */});
            //Register<EmployeeDeletedEvent>(e => _records.RemoveAll(x=> x.Id == e.EmployeeId));
        }
        public DriverAggregate(DriverId id, IEntityGeneratorService generator) : base(id, SnapshotEveryFewVersionsStrategy.With(10))
        {
            Register(_driverAggregateState);

            _generator = generator;
        }
Exemple #11
0
 public Charge(ChargeId id) : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
 }
Exemple #12
0
 public Car(CarId id) : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
 }
Exemple #13
0
 public Booking(BookingId id) : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
     Register(_state);
 }
Exemple #14
0
 public MovieAggregate(MovieId Id) : base(Id, SnapshotEveryFewVersionsStrategy.With(2))
 {
     Register(_movieAggregateState);
 }
Exemple #15
0
 public Location(LocationId id) : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
 }
 public OrderAggregate(OrderId id) : base(id, SnapshotEveryFewVersionsStrategy.With(5))
 {
     Register(_orderState);
 }
Exemple #17
0
 public PaymentAggregate(PaymentId id, IPaymentProviderFactory paymentProviderFactory) : base(id,
                                                                                              SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
     _paymentProviderFactory = paymentProviderFactory;
     Register(_paymentState);
 }
 public VehicleAggregate(VehicleId id) : base(id, SnapshotEveryFewVersionsStrategy.With(10))
 {
     Register(_vehicleAggregateState);
 }
Exemple #19
0
        private bool _inited; // added in order to prevent using init method twice

        public InventoryItemAggregate(InventoryItemId id) : base(id, SnapshotEveryFewVersionsStrategy.With(50))
        {
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompanyAggregate"/> class.
        /// </summary>
        /// <param name="id">The identifier.</param>
        public CompanyAggregate(CompanyId id, IScopedContext scopedContext) : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
        {
            _scopedContext = scopedContext;

            Register <CompanyAddedEvent>(e => _records.Add(id, e.CompanyRecord));
            Register <CompanyEditedEvent>(e => _records[id] = e.CompanyRecord);
            Register <CompanyDeletedEvent>(e => _records.Remove(id));
            Register <CompanySagaStartRequestedEvent>(e => { /* do nothing */ });
            Register <CompanySagaCompleteRequestedEvent>(e => { /* do nothing */ });
        }
 public ExampleAggregate(ExampleId id) : base(id, SnapshotEveryFewVersionsStrategy.With(SnapshotEveryVersion))
 {
     //    SetSourceIdHistory(int.MaxValue); //optional;
 }
Exemple #22
0
 public AccountAggregate(AccountId id) : base(id, SnapshotEveryFewVersionsStrategy.With(5))
 {
 }
Exemple #23
0
 public TicketAggregate(TicketId id) : base(id, SnapshotEveryFewVersionsStrategy.With(2))
 {
     Register(_ticketAggregateState);
 }