/// <summary>
 /// Initializes a new instance of the <see cref="TransactionalHandler" /> class.
 /// </summary>
 /// <param name="adapter">Used to monitor all transactions.</param>
 /// <param name="storage">Used to temporarily store domain events until the transaction have been committed.</param>
 public TransactionalHandler(IUnitOfWorkAdapter adapter, IDomainEventStorage storage)
 {
     if (adapter == null) throw new ArgumentNullException("adapter");
     if (storage == null) throw new ArgumentNullException("storage");
     _storage = storage;
     adapter.Register(this);
 }
Ejemplo n.º 2
0
 public EventStoreUnitOfWork(IDomainEventStorage <TDomainEvent> domainEventStorage, IIdentityMap <TDomainEvent> identityMap, IBus bus)
 {
     _domainEventStorage = domainEventStorage;
     _identityMap        = identityMap;
     _bus            = bus;
     _eventProviders = new List <IEventProvider <TDomainEvent> >();
 }
Ejemplo n.º 3
0
 public void EventStore_MySql_AddDomainEventToStoreTest()
 {
     using (IDomainEventStorage eventStore = application.ObjectContainer.GetService <IDomainEventStorage>())
     {
         var domainEvent = Helper.CreateCreateCustomerDomainEvents()[0];
         eventStore.SaveEvent(domainEvent);
     }
 }
 /// <summary>
 /// Custom strage for events which awaits transaction completition.
 /// </summary>
 /// <param name="storage">Event storage</param>
 /// <returns>this</returns>
 public EventPipelineBuilder StoreEvents(IDomainEventStorage storage)
 {
     if (storage == null)
     {
         throw new ArgumentNullException("storage");
     }
     _storage = storage;
     return(this);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionalHandler" /> class.
 /// </summary>
 /// <param name="adapter">Used to monitor all transactions.</param>
 /// <param name="storage">Used to temporarily store domain events until the transaction have been committed.</param>
 public TransactionalHandler(IUnitOfWorkAdapter adapter, IDomainEventStorage storage)
 {
     if (adapter == null)
     {
         throw new ArgumentNullException("adapter");
     }
     if (storage == null)
     {
         throw new ArgumentNullException("storage");
     }
     _storage = storage;
     adapter.Register(this);
 }
 public void EventStore_SqlExpress_RetrieveAllDomainEventFromStoreTest()
 {
     using (IDomainEventStorage eventStore = application.ObjectContainer.GetService <IDomainEventStorage>())
     {
         foreach (var cce in Helper.CreateCreateCustomerDomainEvents())
         {
             eventStore.SaveEvent(cce);
         }
         //eventStore.Commit();
     }
     using (IDomainEventStorage eventStore = application.ObjectContainer.GetService <IDomainEventStorage>())
     {
         var p = eventStore.LoadEvents(typeof(SourcedCustomer), Helper.AggregateRootId1);
         var q = eventStore.LoadEvents(typeof(SourcedCustomer), Helper.AggregateRootId2);
         var r = eventStore.LoadEvents(typeof(SourcedCustomer), Helper.AggregateRootId3);
         Assert.IsNotNull(p);
         Assert.IsNotNull(q);
         Assert.IsNotNull(r);
         Assert.AreEqual <int>(1, p.Count());
         Assert.AreEqual <int>(1, q.Count());
         Assert.AreEqual <int>(1, r.Count());
     }
 }
 /// <summary>
 /// Initializes a new instance of <c>EventSourcedDomainRepository</c> class.
 /// </summary>
 /// <param name="domainEventStorage">The <see cref="Apworks.Events.Storage.IDomainEventStorage"/> instance
 /// that handles the storage mechanism for domain events.</param>
 /// <param name="eventBus">The <see cref="Apworks.Bus.IEventBus"/> instance to which the domain events
 /// are published.</param>
 /// <param name="snapshotProvider">The <see cref="Apworks.Snapshots.Providers.ISnapshotProvider"/> instance
 /// that is used for handling the snapshot operations.</param>
 public EventSourcedDomainRepository(IDomainEventStorage domainEventStorage, IEventBus eventBus, ISnapshotProvider snapshotProvider)
     : base(eventBus)
 {
     this.domainEventStorage = domainEventStorage;
     this.snapshotProvider   = snapshotProvider;
 }
 /// <summary>
 /// Custom strage for events which awaits transaction completition.
 /// </summary>
 /// <param name="storage">Event storage</param>
 /// <returns>this</returns>
 public EventPipelineBuilder StoreEvents(IDomainEventStorage storage)
 {
     if (storage == null) throw new ArgumentNullException("storage");
     _storage = storage;
     return this;
 }
 public EventSourceDomainRepository(IDomainEventStorage domainEventStorage, IEventBus eventBus) : base(eventBus)
 {
     this.domainEventStorage = domainEventStorage;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 初始化一个 <c>EventSourcedDomainRepository</c> 类实例。
 /// </summary>
 /// <param name="domainEventStorage">一个 <see cref="Anycmd.Events.Storage.IDomainEventStorage{T}"/>
 /// 类型的实例,该实例是一种储存领域事件的装置。</param>
 /// <param name="eventBus">一个 <see cref="Anycmd.Bus.IEventBus"/> 类型的事件总线对象,领域事件发向该总线。</param>
 /// <param name="snapshotProvider"><see cref="Anycmd.Snapshots.Providers.ISnapshotProvider{T}"/>
 /// 处理快照操作的快照提供程序。</param>
 public EventSourcedDomainRepository(IDomainEventStorage <TAggregateRootId> domainEventStorage, IEventBus eventBus, ISnapshotProvider <TAggregateRootId> snapshotProvider)
     : base(eventBus)
 {
     this._domainEventStorage = domainEventStorage;
     this._snapshotProvider   = snapshotProvider;
 }
 public TinyLibraryCQRSDomainRepository(IDomainEventStorage domainEventStorage, IEventBus eventBus, ISnapshotProvider snapshotProvider)
     : base(domainEventStorage, eventBus, snapshotProvider)
 {
 }