Documentation Coverage Report
Current view: top level - Ninject/Azure/Cqrs.Ninject.Azure.Wcf - CqrsWebHost.cs Hit Total Coverage
Version: 2.2 Artefacts: 6 6 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.Collections.Generic;
      10             : using Cqrs.Authentication;
      11             : using Cqrs.Azure.ConfigurationManager;
      12             : using Cqrs.Commands;
      13             : using Cqrs.Configuration;
      14             : using Cqrs.Events;
      15             : using Cqrs.Ninject.Azure.ServiceBus.CommandBus.Configuration;
      16             : using Cqrs.Ninject.Azure.ServiceBus.EventBus.Configuration;
      17             : using Cqrs.Ninject.Azure.Wcf.Configuration;
      18             : using Cqrs.Ninject.Configuration;
      19             : using Ninject.Modules;
      20             : 
      21             : namespace Cqrs.Ninject.Azure.Wcf
      22             : {
      23             :         /// <summary>
      24             :         /// Execute command and event handlers in a WCF Host using Ninject, defaulting to <see cref="WebHostModule"/> as the module to load.
      25             :         /// </summary>
      26             :         public class CqrsWebHost<TAuthenticationToken, TAuthenticationTokenHelper> : CqrsWebHost<TAuthenticationToken, TAuthenticationTokenHelper, WebHostModule>
      27             :                 where TAuthenticationTokenHelper : class, IAuthenticationTokenHelper<TAuthenticationToken>
      28             :         {
      29             :         }
      30             : 
      31             :         /// <summary>
      32             :         /// Execute command and event handlers in a WCF Host using Ninject
      33             :         /// </summary>
      34             :         public class CqrsWebHost<TAuthenticationToken, TAuthenticationTokenHelper, TWebHostModule> : TelemetryCoreHost<TAuthenticationToken>
      35             :                 where TAuthenticationTokenHelper : class, IAuthenticationTokenHelper<TAuthenticationToken>
      36             :                 where TWebHostModule : WebHostModule, new ()
      37           2 :         {
      38             :                 #region Overrides of CoreHost
      39             : 
      40             :                 /// <summary>
      41             :                 /// Configure the <see cref="DependencyResolver"/>.
      42             :                 /// </summary>
      43           2 :                 protected override void ConfigureDefaultDependencyResolver()
      44             :                 {
      45             :                         foreach (INinjectModule supplementaryModule in GetSupplementaryModules())
      46             :                                 NinjectDependencyResolver.ModulesToLoad.Add(supplementaryModule);
      47             : 
      48             :                         NinjectDependencyResolver.Start(prepareProvidedKernel: true);
      49             :                 }
      50             : 
      51             :                 #endregion
      52             : 
      53             :                 /// <summary>
      54             :                 /// A collection of <see cref="INinjectModule"/> that are required to be loaded
      55             :                 /// </summary>
      56           2 :                 protected virtual IEnumerable<INinjectModule> GetSupplementaryModules()
      57             :                 {
      58             :                         var results = new List<INinjectModule>
      59             :                         {
      60             :                                 new TWebHostModule(),
      61             :                                 new CqrsModule<TAuthenticationToken, TAuthenticationTokenHelper>(true, true)
      62             :                         };
      63             : 
      64             :                         results.AddRange(GetCommandBusModules());
      65             :                         results.AddRange(GetEventBusModules());
      66             :                         results.AddRange(GetEventStoreModules());
      67             : 
      68             :                         return results;
      69             :                 }
      70             : 
      71             :                 /// <summary>
      72             :                 /// A collection of <see cref="INinjectModule"/> that configure the Azure Servicebus as a command bus as both
      73             :                 /// <see cref="ICommandPublisher{TAuthenticationToken}"/> and <see cref="ICommandReceiver{TAuthenticationToken}"/>.
      74             :                 /// </summary>
      75           2 :                 protected virtual IEnumerable<INinjectModule> GetCommandBusModules()
      76             :                 {
      77             :                         return new List<INinjectModule>
      78             :                         {
      79             :                                 new AzureCommandBusReceiverModule<TAuthenticationToken>(),
      80             :                                 new AzureCommandBusPublisherModule<TAuthenticationToken>()
      81             :                         };
      82             :                 }
      83             : 
      84             :                 /// <summary>
      85             :                 /// A collection of <see cref="INinjectModule"/> that configure the Azure Servicebus as a event bus as both
      86             :                 /// <see cref="IEventPublisher{TAuthenticationToken}"/> and <see cref="IEventReceiver{TAuthenticationToken}"/>
      87             :                 /// If the app setting Cqrs.Host.EnableEventReceiving is "false" then no modules will be returned.
      88             :                 /// </summary>
      89           2 :                 protected virtual IEnumerable<INinjectModule> GetEventBusModules()
      90             :                 {
      91             :                         return new List<INinjectModule>
      92             :                         {
      93             :                                 new AzureEventBusReceiverModule<TAuthenticationToken>(),
      94             :                                 new AzureEventBusPublisherModule<TAuthenticationToken>()
      95             :                         };
      96             :                 }
      97             : 
      98             :                 /// <summary>
      99             :                 /// A collection of <see cref="INinjectModule"/> that configure SQL server as the <see cref="IEventStore{TAuthenticationToken}"/>
     100             :                 /// </summary>
     101           2 :                 protected virtual IEnumerable<INinjectModule> GetEventStoreModules()
     102             :                 {
     103             :                         return new List<INinjectModule>
     104             :                         {
     105             :                                 new SimplifiedSqlModule<TAuthenticationToken>()
     106             :                         };
     107             :                 }
     108             :         }
     109             : }

Generated by: LCOV version 1.12