Documentation Coverage Report
Current view: top level - Ninject/Azure/Cqrs.Ninject.Azure.ServiceBus.CommandBus/Configuration - AzureCommandBusPublisherModule.cs Hit Total Coverage
Version: 2.2 Artefacts: 4 4 100.0 %
Date: 2018-08-07 15:04:50

          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.Commands;
      13             : using Ninject.Modules;
      14             : 
      15             : namespace Cqrs.Ninject.Azure.ServiceBus.CommandBus.Configuration
      16             : {
      17             :         /// <summary>
      18             :         /// A <see cref="INinjectModule"/> that wires up <see cref="AzureCommandBusPublisher{TAuthenticationToken}"/> as the <see cref="ICommandPublisher{TAuthenticationToken}"/> and other require components.
      19             :         /// </summary>
      20             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
      21             :         public class AzureCommandBusPublisherModule<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             :                         RegisterCommandSender();
      39             :                         RegisterCommandMessageSerialiser();
      40             :                 }
      41             : 
      42             :                 #endregion
      43             : 
      44             :                 /// <summary>
      45             :                 /// Register the CQRS command publisher
      46             :                 /// </summary>
      47           1 :                 public virtual void RegisterCommandSender()
      48             :                 {
      49             :                         Bind<ICommandPublisher<TAuthenticationToken>>()
      50             :                                 .To<AzureCommandBusPublisher<TAuthenticationToken>>()
      51             :                                 .InSingletonScope();
      52             : 
      53             :                         Bind<IPublishAndWaitCommandPublisher<TAuthenticationToken>>()
      54             :                                 .To<AzureCommandBusPublisher<TAuthenticationToken>>()
      55             :                                 .InSingletonScope();
      56             :                 }
      57             : 
      58             :                 /// <summary>
      59             :                 /// Register the CQRS command handler message serialiser
      60             :                 /// </summary>
      61           1 :                 public virtual void RegisterCommandMessageSerialiser()
      62             :                 {
      63             :                         bool isMessageSerialiserBound = Kernel.GetBindings(typeof(IMessageSerialiser<TAuthenticationToken>)).Any();
      64             :                         if (!isMessageSerialiserBound)
      65             :                         {
      66             :                                 Bind<IMessageSerialiser<TAuthenticationToken>>()
      67             :                                         .To<MessageSerialiser<TAuthenticationToken>>()
      68             :                                         .InSingletonScope();
      69             :                         }
      70             :                 }
      71             :         }
      72             : }

Generated by: LCOV version 1.12