Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="cdmdotnet Limited">
4 : // // Copyright cdmdotnet Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Threading.Tasks;
11 : using cdmdotnet.Logging;
12 : using Cqrs.Akka.Events;
13 : using Cqrs.Domain;
14 : using Cqrs.Domain.Factories;
15 : using Cqrs.Events;
16 :
17 : namespace Cqrs.Akka.Domain
18 : {
19 : public class AkkaRepository<TAuthenticationToken>
20 : : Repository<TAuthenticationToken>
21 : , IAkkaRepository<TAuthenticationToken>
22 0 : {
23 : protected IAkkaEventPublisherProxy<TAuthenticationToken> EventPublisher { get; private set; }
24 :
25 0 : public AkkaRepository(IAggregateFactory aggregateFactory, IEventStore<TAuthenticationToken> eventStore, IEventPublisher<TAuthenticationToken> publisher, ICorrelationIdHelper correlationIdHelper, IAkkaEventPublisherProxy<TAuthenticationToken> eventPublisher)
26 : : base(aggregateFactory, eventStore, publisher, correlationIdHelper)
27 : {
28 : EventPublisher = eventPublisher;
29 : }
30 :
31 : #region Overrides of Repository<TAuthenticationToken>
32 :
33 0 : protected override TAggregateRoot CreateAggregate<TAggregateRoot>(Guid id)
34 : {
35 : var aggregate = AggregateFactory.CreateAggregate<TAggregateRoot>();
36 :
37 : return aggregate;
38 : }
39 :
40 0 : protected override void PublishEvent(IEvent<TAuthenticationToken> @event)
41 : {
42 : Task.Factory.StartNewSafely(() =>
43 : {
44 : EventPublisher.Publish(@event);
45 : base.PublishEvent(@event);
46 : });
47 : }
48 :
49 : #endregion
50 : }
51 : }
|