Documentation Coverage Report
Current view: top level - Ninject/Azure/Cqrs.Ninject.Azure.Wcf - CqrsWebHost.cs Hit Total Coverage
Version: 4.0 Artefacts: 6 6 100.0 %
Date: 2019-11-24 03:15:41

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

Generated by: LCOV version 1.13