Beispiel #1
0
 public SnapshotAggregateRepository(ISnapshotRepository repository, IAggregateManifestRepository manifest, INotificationEventBus eventBus)
 {
     this.repository = repository;
     this.eventBus   = eventBus;
     this.manifest   = manifest;
     this.changes    = new Subject <IDataChangeEvent>();
 }
 public EventSourcedAggregateRepository(IEventSerializer serializer, IEventStoreRepository repository, IAggregateManifestRepository manifest, INotificationEventBus eventBus)
 {
     this.serializer = serializer;
     this.repository = repository;
     this.eventBus   = eventBus;
     this.manifest   = manifest;
 }
Beispiel #3
0
        public virtual IAggregateRepository <T> GetAggregateRepository <T>(INotificationEventBus bus) where T : IAggregateRoot, new()
        {
            if (typeof(T).GetInterfaces().Contains(typeof(IEventSourced)))
            {
                return(new EventSourcedAggregateRepository <T>(this.EventSerializer, this.EventStore, this.Manifest, new ReadModelBuildingEventBus <T>(this, bus)));
            }

            var repo = new SnapshotAggregateRepository <T>(this.GetSnapshotRepository(typeof(T)), this.Manifest, new ReadModelBuildingEventBus <T>(this, bus));

            if (repo as IObservableRepository != null)
            {
                ((IObservableRepository)repo).Changes.Subscribe(evt => bus.Publish(evt.AsDomainEvent()));
            }

            return(repo);
        }
Beispiel #4
0
        public IList <IReadModelBuilder> GetReadModelBuilders <T>(INotificationEventBus bus) where T : IAggregateRoot, new()
        {
            var result = new List <IReadModelBuilder>();

            if (this.registeredBuilders.ContainsKey(typeof(T)))
            {
                foreach (var factory in this.registeredBuilders[typeof(T)])
                {
                    var repo = factory(this);

                    if (repo as IObservableRepository != null)
                    {
                        ((IObservableRepository)repo).Changes.Subscribe(evt => bus.Publish(evt.AsDomainEvent()));
                    }

                    result.Add(repo);
                }
            }

            return(result);
        }
Beispiel #5
0
 public UnitOfWorkEventBus(INotificationEventBus bus)
 {
     this.events = new List <INotificationEvent>();
     this.bus    = bus;
 }
Beispiel #6
0
        public DomainContext(IAggregateManifestRepository manifest, IEventStoreRepository eventStore, INotificationEventBus eventBus)
        {
            this.Manifest   = manifest;
            this.EventBus   = eventBus;
            this.EventStore = eventStore;

            this.registeredBuilders             = new Dictionary <Type, List <Func <IDomainContext, IReadModelBuilder> > >();
            this.registeredSnapshotRepositories = new Dictionary <Type, Func <IDomainContext, ISnapshotRepository> >();
        }
 public ReadModelBuildingEventBus(IDomainContext context, INotificationEventBus bus)
 {
     this.context = context;
     this.bus     = bus;
 }
Beispiel #8
0
 public UnitOfWorkEventBus(INotificationEventBus bus)
 {
     this.events = new List<INotificationEvent>();
     this.bus = bus;
 }