Documentation Coverage Report
Current view: top level - Akka.Net/Cqrs.Akka/Domain - AkkaAggregateRepository.cs Hit Total Coverage
Version: 2.2 Artefacts: 4 4 100.0 %
Date: 2017-09-22

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="Chinchilla Software Limited">
       4             : // //   Copyright Chinchilla Software 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             :         /// <summary>
      20             :         /// A <see cref="AggregateRepository{TAuthenticationToken}"/> that is safe to use within Akka.NET
      21             :         /// </summary>
      22             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of authentication token.</typeparam>
      23             :         public class AkkaAggregateRepository<TAuthenticationToken>
      24             :                 : AggregateRepository<TAuthenticationToken>
      25             :                 , IAkkaAggregateRepository<TAuthenticationToken>
      26           1 :         {
      27             :                 /// <summary>
      28             :                 /// Gets the <see cref="IAkkaEventPublisherProxy{TAuthenticationToken}"/>
      29             :                 /// </summary>
      30             :                 protected IAkkaEventPublisherProxy<TAuthenticationToken> EventPublisher { get; private set; }
      31             : 
      32             :                 /// <summary>
      33             :                 /// Instantiates a new instance of <see cref="AkkaAggregateRepository{TAuthenticationToken}"/>
      34             :                 /// </summary>
      35           1 :                 public AkkaAggregateRepository(IAggregateFactory aggregateFactory, IEventStore<TAuthenticationToken> eventStore, IEventPublisher<TAuthenticationToken> publisher, ICorrelationIdHelper correlationIdHelper, IAkkaEventPublisherProxy<TAuthenticationToken> eventPublisher)
      36             :                         : base(aggregateFactory, eventStore, publisher, correlationIdHelper)
      37             :                 {
      38             :                         EventPublisher = eventPublisher;
      39             :                 }
      40             : 
      41             :                 #region Overrides of Repository<TAuthenticationToken>
      42             : 
      43             :                 /// <summary>
      44             :                 /// Calls <see cref="IAggregateFactory.Create"/> to get a, <typeparamref name="TAggregateRoot"/>.
      45             :                 /// </summary>
      46             :                 /// <typeparam name="TAggregateRoot">The <see cref="Type"/> of <see cref="IAggregateRoot{TAuthenticationToken}"/>.</typeparam>
      47             :                 /// <param name="id">The id of the <typeparamref name="TAggregateRoot"/> to create.</param>
      48           1 :                 protected override TAggregateRoot CreateAggregate<TAggregateRoot>(Guid id)
      49             :                 {
      50             :                         var aggregate = AggregateFactory.Create<TAggregateRoot>();
      51             : 
      52             :                         return aggregate;
      53             :                 }
      54             : 
      55             :                 /// <summary>
      56             :                 /// Publish the saved <paramref name="event"/> asynchronously on <see cref="EventPublisher"/>,
      57             :                 /// then calls <see cref="AggregateRepository{TAuthenticationToken}.PublishEvent"/>
      58             :                 /// </summary>
      59           1 :                 protected override void PublishEvent(IEvent<TAuthenticationToken> @event)
      60             :                 {
      61             :                         Task.Factory.StartNewSafely(() =>
      62             :                         {
      63             :                                 EventPublisher.Publish(@event);
      64             :                                 base.PublishEvent(@event);
      65             :                         });
      66             :                 }
      67             : 
      68             :                 #endregion
      69             :         }
      70             : }

Generated by: LCOV version 1.10