Documentation Coverage Report
Current view: top level - Akka.Net/Cqrs.Akka/Domain - AkkaSagaProxy.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="ISaga{TAuthenticationToken}"/>.
      20             :         /// </summary>
      21             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of authentication token.</typeparam>
      22             :         /// <typeparam name="TSaga">The <see cref="Type"/> of <see cref="ISaga{TAuthenticationToken}"/>.</typeparam>
      23             :         public class AkkaSagaProxy<TAuthenticationToken, TSaga>
      24             :                 : IAkkaSagaProxy<TSaga>
      25             :                 , ISaga<TAuthenticationToken>
      26             :                 // TODO think about if this is necessary again.
      27             :                 // where TSaga : ISaga<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="TSaga"/>.
      36             :                 /// </summary>
      37             :                 public TSaga Saga { get; protected set; }
      38             : 
      39             :                 #region Implementation of ISaga<TAuthenticationToken>
      40             : 
      41             :                 /// <summary>
      42             :                 /// The identifier of the <see cref="ISaga{TAuthenticationToken}"/>.
      43             :                 /// </summary>
      44             :                 public virtual Guid Id
      45             :                 {
      46             :                         get { return ActorReference.Ask<Guid>(new GetAkkaSagaId()).Result; }
      47             :                 }
      48             : 
      49             :                 /// <summary>
      50             :                 /// The current version of this <see cref="ISaga{TAuthenticationToken}"/>.
      51             :                 /// </summary>
      52             :                 public virtual int Version
      53             :                 {
      54             :                         get { return ActorReference.Ask<int>(new GetAkkaSagaVersion()).Result; }
      55             :                 }
      56             : 
      57             :                 /// <summary>
      58             :                 /// Get all applied changes that haven't yet been committed.
      59             :                 /// </summary>
      60           1 :                 public virtual IEnumerable<ISagaEvent<TAuthenticationToken>> GetUncommittedChanges()
      61             :                 {
      62             :                         return ((ISaga<TAuthenticationToken>)Saga).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             :                         ((ISaga<TAuthenticationToken>)Saga).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<ISagaEvent<TAuthenticationToken>> history)
      78             :                 {
      79             :                         ((ISaga<TAuthenticationToken>)Saga).LoadFromHistory(history);
      80             :                 }
      81             : 
      82             :                 #endregion
      83             :         }
      84             : }

Generated by: LCOV version 1.10