LCOV - code coverage report
Current view: top level - Akka.Net/Cqrs.Akka/Events - AkkaEventHandler.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 3 0.0 %
Date: 2017-07-26

          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.Collections.Generic;
      11             : using Akka.Actor;
      12             : using cdmdotnet.Logging;
      13             : using Cqrs.Authentication;
      14             : using Cqrs.Events;
      15             : 
      16             : namespace Cqrs.Akka.Events
      17             : {
      18             :         public abstract class AkkaEventHandler<TAuthenticationToken>
      19             :                 : ReceiveActor // PersistentActor 
      20           0 :         {
      21             :                 protected ILogger Logger { get; set; }
      22             : 
      23             :                 protected ICorrelationIdHelper CorrelationIdHelper { get; private set; }
      24             : 
      25             :                 protected IAuthenticationTokenHelper<TAuthenticationToken> AuthenticationTokenHelper { get; private set; }
      26             : 
      27           0 :                 protected AkkaEventHandler(ILogger logger, ICorrelationIdHelper correlationIdHelper, IAuthenticationTokenHelper<TAuthenticationToken> authenticationTokenHelper)
      28             :                 {
      29             :                         Logger = logger;
      30             :                         CorrelationIdHelper = correlationIdHelper;
      31             :                         AuthenticationTokenHelper = authenticationTokenHelper;
      32             :                 }
      33             : 
      34           0 :                 protected virtual void Execute<TEvent>(Action<TEvent> handler, TEvent @event)
      35             :                         where TEvent : IEvent<TAuthenticationToken>
      36             :                 {
      37             :                         try
      38             :                         {
      39             :                                 AuthenticationTokenHelper.SetAuthenticationToken(@event.AuthenticationToken);
      40             :                                 CorrelationIdHelper.SetCorrelationId(@event.CorrelationId);
      41             :                                 handler(@event);
      42             : 
      43             :                                 Sender.Tell(true, Self);
      44             :                         }
      45             :                         catch(Exception exception)
      46             :                         {
      47             :                                 Logger.LogError("Executing an Akka.net request failed.", exception: exception, metaData: new Dictionary<string, object> { { "Type", GetType() }, { "Event", @event} });
      48             :                                 Sender.Tell(false, Self);
      49             :                                 throw;
      50             :                         }
      51             :                 }
      52             :         }
      53             : }

Generated by: LCOV version 1.10