Documentation Coverage Report
Current view: top level - Ninject/Azure/Cqrs.Ninject.Azure.ServiceBus.EventBus/Configuration - AzureEventBusPublisherModule.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.Linq;
      11             : using Cqrs.Azure.ServiceBus;
      12             : using Cqrs.Events;
      13             : using Ninject.Modules;
      14             : 
      15             : namespace Cqrs.Ninject.Azure.ServiceBus.EventBus.Configuration
      16             : {
      17             :         /// <summary>
      18             :         /// A <see cref="INinjectModule"/> that wires up <see cref="AzureEventBusPublisher{TAuthenticationToken}"/> as the <see cref="IEventPublisher{TAuthenticationToken}"/> and other require components.
      19             :         /// </summary>
      20             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
      21             :         public class AzureEventBusPublisherModule<TAuthenticationToken> : NinjectModule
      22           1 :         {
      23             :                 #region Overrides of NinjectModule
      24             : 
      25             :                 /// <summary>
      26             :                 /// Loads the module into the kernel.
      27             :                 /// </summary>
      28           1 :                 public override void Load()
      29             :                 {
      30             :                         bool isMessageSerialiserBound = Kernel.GetBindings(typeof(IAzureBusHelper<TAuthenticationToken>)).Any();
      31             :                         if (!isMessageSerialiserBound)
      32             :                         {
      33             :                                 Bind<IAzureBusHelper<TAuthenticationToken>>()
      34             :                                         .To<AzureBusHelper<TAuthenticationToken>>()
      35             :                                         .InSingletonScope();
      36             :                         }
      37             : 
      38             :                         RegisterEventPublisher();
      39             :                         RegisterEventMessageSerialiser();
      40             :                 }
      41             : 
      42             :                 #endregion
      43             : 
      44             :                 /// <summary>
      45             :                 /// Register the CQRS event publisher
      46             :                 /// </summary>
      47           1 :                 public virtual void RegisterEventPublisher()
      48             :                 {
      49             :                         Bind<IEventPublisher<TAuthenticationToken>>()
      50             :                                 .To<AzureEventBusPublisher<TAuthenticationToken>>()
      51             :                                 .InSingletonScope();
      52             :                 }
      53             : 
      54             :                 /// <summary>
      55             :                 /// Register the CQRS event handler message serialiser
      56             :                 /// </summary>
      57           1 :                 public virtual void RegisterEventMessageSerialiser()
      58             :                 {
      59             :                         bool isMessageSerialiserBound = Kernel.GetBindings(typeof(IMessageSerialiser<TAuthenticationToken>)).Any();
      60             :                         if (!isMessageSerialiserBound)
      61             :                         {
      62             :                                 Bind<IMessageSerialiser<TAuthenticationToken>>()
      63             :                                         .To<MessageSerialiser<TAuthenticationToken>>()
      64             :                                         .InSingletonScope();
      65             :                         }
      66             :                 }
      67             :         }
      68             : }

Generated by: LCOV version 1.10