Documentation Coverage Report
Current view: top level - Akka.Net/Cqrs.Akka/Domain - AkkaAggregateRootProxy.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.Collections.Generic;
      11             : using Akka.Actor;
      12             : using Cqrs.Akka.Domain.Commands;
      13             : using Cqrs.Domain;
      14             : using Cqrs.Events;
      15             : 
      16             : namespace Cqrs.Akka.Domain
      17             : {
      18             :         /// <summary>
      19             :         /// A remote proxy to an <see cref="IAggregateRoot{TAuthenticationToken}"/>.
      20             :         /// </summary>
      21             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of authentication token.</typeparam>
      22             :         /// <typeparam name="TAggregateRoot">The <see cref="Type"/> of <see cref="IAggregateRoot{TAuthenticationToken}"/>.</typeparam>
      23             :         public class AkkaAggregateRootProxy<TAuthenticationToken, TAggregateRoot>
      24             :                 : IAkkaAggregateRootProxy<TAggregateRoot>
      25             :                 , IAggregateRoot<TAuthenticationToken>
      26             :                 // TODO think about if this is necessary again.
      27             :                 // where TAggregateRoot : IAggregateRoot<TAuthenticationToken>
      28           1 :         {
      29             :                 /// <summary>
      30             :                 /// Gets the <see cref="IActorRef"/>.
      31             :                 /// </summary>
      32             :                 public IActorRef ActorReference { get; internal set; }
      33             : 
      34             :                 /// <summary>
      35             :                 /// Gets the <typeparamref name="TAggregateRoot"/>.
      36             :                 /// </summary>
      37             :                 public TAggregateRoot Aggregate { get; protected set; }
      38             : 
      39             :                 #region Implementation of IAggregateRoot<TAuthenticationToken>
      40             : 
      41             :                 /// <summary>
      42             :                 /// The identifier of this <see cref="IAggregateRoot{TAuthenticationToken}"/>.
      43             :                 /// </summary>
      44             :                 public virtual Guid Id
      45             :                 {
      46             :                         get { return ActorReference.Ask<Guid>(new GetAkkaAggregateRootId()).Result; }
      47             :                 }
      48             : 
      49             :                 /// <summary>
      50             :                 /// The current version of this <see cref="IAggregateRoot{TAuthenticationToken}"/>.
      51             :                 /// </summary>
      52             :                 public virtual int Version
      53             :                 {
      54             :                         get { return ActorReference.Ask<int>(new GetAkkaAggregateRootVersion()).Result; }
      55             :                 }
      56             : 
      57             :                 /// <summary>
      58             :                 /// Get all applied changes that haven't yet been committed.
      59             :                 /// </summary>
      60           1 :                 public virtual IEnumerable<IEvent<TAuthenticationToken>> GetUncommittedChanges()
      61             :                 {
      62             :                         return ((IAggregateRoot<TAuthenticationToken>)Aggregate).GetUncommittedChanges();
      63             :                 }
      64             : 
      65             :                 /// <summary>
      66             :                 /// Mark all applied changes as committed, increment <see cref="Version"/> and flush the internal collection of changes.
      67             :                 /// </summary>
      68           1 :                 public virtual void MarkChangesAsCommitted()
      69             :                 {
      70             :                         ((IAggregateRoot<TAuthenticationToken>)Aggregate).MarkChangesAsCommitted();
      71             :                 }
      72             : 
      73             :                 /// <summary>
      74             :                 /// Apply all the <see cref="IEvent{TAuthenticationToken}">events</see> in <paramref name="history"/>
      75             :                 /// using event replay to this instance.
      76             :                 /// </summary>
      77           1 :                 public virtual void LoadFromHistory(IEnumerable<IEvent<TAuthenticationToken>> history)
      78             :                 {
      79             :                         ((IAggregateRoot<TAuthenticationToken>)Aggregate).LoadFromHistory(history);
      80             :                 }
      81             : 
      82             :                 #endregion
      83             :         }
      84             : }

Generated by: LCOV version 1.10