Documentation Coverage Report
Current view: top level - Ninject/Azure/Cqrs.Ninject.Azure.DocumentDb/Configuration - AzureDocumentDbEventStoreModule.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;
      10             : using System.Linq;
      11             : using Cqrs.Azure.DocumentDb;
      12             : using Cqrs.Azure.DocumentDb.Events;
      13             : using Cqrs.Events;
      14             : using Cqrs.Snapshots;
      15             : using Ninject.Modules;
      16             : 
      17             : namespace Cqrs.Ninject.Azure.DocumentDb.Configuration
      18             : {
      19             :         /// <summary>
      20             :         /// A <see cref="INinjectModule"/> that wires up <see cref="AzureDocumentDbEventStore{TAuthenticationToken}"/> as the <see cref="IEventStore{TAuthenticationToken}"/>.
      21             :         /// </summary>
      22             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
      23             :         public class AzureDocumentDbEventStoreModule<TAuthenticationToken> : NinjectModule
      24           1 :         {
      25             :                 #region Overrides of NinjectModule
      26             : 
      27             :                 /// <summary>
      28             :                 /// Loads the module into the kernel.
      29             :                 /// </summary>
      30           1 :                 public override void Load()
      31             :                 {
      32             :                         RegisterFactories();
      33             :                         RegisterServices();
      34             :                         RegisterEventStore();
      35             :                         RegisterAzureHelpers();
      36             :                 }
      37             : 
      38             :                 #endregion
      39             : 
      40             :                 /// <summary>
      41             :                 /// Register the all factories
      42             :                 /// </summary>
      43           1 :                 public virtual void RegisterFactories()
      44             :                 {
      45             :                         Bind<IEventBuilder<TAuthenticationToken>>()
      46             :                                 .To<DefaultEventBuilder<TAuthenticationToken>>()
      47             :                                 .InSingletonScope();
      48             :                         Bind<IEventDeserialiser<TAuthenticationToken>>()
      49             :                                 .To<EventDeserialiser<TAuthenticationToken>>()
      50             :                                 .InSingletonScope();
      51             :                         Bind<ISnapshotDeserialiser>()
      52             :                                 .To<SnapshotDeserialiser>()
      53             :                                 .InSingletonScope();
      54             :                 }
      55             : 
      56             :                 /// <summary>
      57             :                 /// Register the all services
      58             :                 /// </summary>
      59           1 :                 public virtual void RegisterServices()
      60             :                 {
      61             :                 }
      62             : 
      63             :                 /// <summary>
      64             :                 /// Register <see cref="IAzureDocumentDbHelper"/> if it hasn't already been registered.
      65             :                 /// </summary>
      66           1 :                 public virtual void RegisterAzureHelpers()
      67             :                 {
      68             :                         if (!Kernel.GetBindings(typeof(IAzureDocumentDbHelper)).Any())
      69             :                         {
      70             :                                 Bind<IAzureDocumentDbHelper>()
      71             :                                         .To<AzureDocumentDbHelper>()
      72             :                                         .InSingletonScope();
      73             :                         }
      74             :                 }
      75             : 
      76             :                 /// <summary>
      77             :                 /// Register the <see cref="IAzureDocumentDbEventStoreConnectionStringFactory"/> and <see cref="IEventStore{TAuthenticationToken}"/>
      78             :                 /// </summary>
      79           1 :                 public virtual void RegisterEventStore()
      80             :                 {
      81             :                         Bind<IAzureDocumentDbEventStoreConnectionStringFactory>()
      82             :                                 .To<AzureDocumentDbEventStoreConnectionStringFactory>()
      83             :                                 .InSingletonScope();
      84             :                         Bind<IAzureDocumentDbSnapshotStoreConnectionStringFactory>()
      85             :                                 .To<AzureDocumentDbSnapshotStoreConnectionStringFactory>()
      86             :                                 .InSingletonScope();
      87             : 
      88             :                         Bind<IEventStore<TAuthenticationToken>>()
      89             :                                 .To<AzureDocumentDbEventStore<TAuthenticationToken>>()
      90             :                                 .InSingletonScope();
      91             :                         Bind<ISnapshotStore>()
      92             :                                 .To<AzureDocumentDbSnapshotStore>()
      93             :                                 .InSingletonScope();
      94             :                 }
      95             :         }
      96             : }

Generated by: LCOV version 1.12