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

          Line data    Source code
       1             : using System;
       2             : using cdmdotnet.Logging;
       3             : using Cqrs.Authentication;
       4             : using Cqrs.Events;
       5             : using Cqrs.WebApi.SignalR.Hubs;
       6             : 
       7             : namespace Cqrs.WebApi.Events.Handlers
       8             : {
       9             :         public abstract class SingleSignOnTokenEventToHubProxy<TSingleSignOnToken>
      10             :                 where TSingleSignOnToken : ISingleSignOnToken, new()
      11           0 :         {
      12           0 :                 protected SingleSignOnTokenEventToHubProxy(ILogger logger, INotificationHub notificationHub, IAuthenticationTokenHelper<TSingleSignOnToken> authenticationTokenHelper)
      13             :                 {
      14             :                         Logger = logger;
      15             :                         NotificationHub = notificationHub;
      16             :                         AuthenticationTokenHelper = authenticationTokenHelper;
      17             :                 }
      18             : 
      19             :                 protected ILogger Logger { get; private set; }
      20             : 
      21             :                 protected INotificationHub NotificationHub { get; private set; }
      22             : 
      23             :                 protected IAuthenticationTokenHelper<TSingleSignOnToken> AuthenticationTokenHelper { get; private set; }
      24             : 
      25           0 :                 protected virtual void HandleGenericEvent(IEvent<TSingleSignOnToken> message)
      26             :                 {
      27             :                         Type eventType = message.GetType();
      28             :                         var notifyCallerEventAttribute = Attribute.GetCustomAttribute(eventType, typeof(NotifyCallerEventAttribute)) as NotifyCallerEventAttribute;
      29             :                         var notifyEveryoneEventAttribute = Attribute.GetCustomAttribute(eventType, typeof(NotifyEveryoneEventAttribute)) as NotifyEveryoneEventAttribute;
      30             :                         var notifyEveryoneExceptCallerEventAttribute = Attribute.GetCustomAttribute(eventType, typeof(NotifyEveryoneExceptCallerEventAttribute)) as NotifyEveryoneExceptCallerEventAttribute;
      31             : 
      32             :                         string userToken = (AuthenticationTokenHelper.GetAuthenticationToken().Token ?? string.Empty).Replace(".", string.Empty);
      33             : 
      34             :                         if (notifyCallerEventAttribute != null)
      35             :                         {
      36             :                                 NotificationHub.SendUserEvent(message, userToken);
      37             :                         }
      38             :                         if (notifyEveryoneEventAttribute != null)
      39             :                         {
      40             :                                 NotificationHub.SendAllUsersEvent(message);
      41             :                         }
      42             :                         if (notifyEveryoneExceptCallerEventAttribute != null)
      43             :                         {
      44             :                                 NotificationHub.SendExceptThisUserEvent(message, userToken);
      45             :                         }
      46             :                 }
      47             :         }
      48             : }

Generated by: LCOV version 1.10