Documentation Coverage Report
Current view: top level - Ninject/Cqrs.Ninject.WebApi/Configuration - SimplifiedNinjectWebApi.cs Hit Total Coverage
Version: 2.2 Artefacts: 5 5 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 Cqrs.Authentication;
      10             : using Cqrs.Configuration;
      11             : using Cqrs.Ninject.Configuration;
      12             : using Microsoft.Web.Infrastructure.DynamicModuleHelper;
      13             : using Ninject;
      14             : using Ninject.Web.Common;
      15             : 
      16             : [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Cqrs.Ninject.WebApi.Configuration.SimplifiedNinjectWebApi), "Start", Order = 50)]
      17             : [assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(Cqrs.Ninject.WebApi.Configuration.SimplifiedNinjectWebApi), "Stop", Order = 50)]
      18             : 
      19             : namespace Cqrs.Ninject.WebApi.Configuration
      20             : {
      21             :         /// <summary>
      22             :         /// A <see cref="WebActivatorEx.PreApplicationStartMethodAttribute"/> that calls <see cref="Start"/>
      23             :         /// and <see cref="WebActivatorEx.ApplicationShutdownMethodAttribute"/> that calls <see cref="Stop"/>
      24             :         /// configuring Simplified SQL by wiring up <see cref="SimplifiedSqlModule{TAuthenticationToken}"/>.
      25             :         /// </summary>
      26             :         public static class SimplifiedNinjectWebApi
      27           1 :         {
      28             :                 private static readonly Bootstrapper Bootstrapper = new Bootstrapper();
      29             : 
      30             :                 /// <summary>
      31             :                 /// Starts the application.
      32             :                 /// </summary>
      33           1 :                 public static void Start()
      34             :                 {
      35             :                         DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
      36             :                         DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
      37             :                         Bootstrapper.Initialize(CreateKernel);
      38             :                 }
      39             : 
      40             :                 /// <summary>
      41             :                 /// Stops the application.
      42             :                 /// </summary>
      43           1 :                 public static void Stop()
      44             :                 {
      45             :                         Bootstrapper.ShutDown();
      46             :                 }
      47             : 
      48             :                 /// <summary>
      49             :                 /// Creates the kernel that will manage your application by instantiating a new instance of <see cref="WebApiStartUp"/>.
      50             :                 /// </summary>
      51             :                 /// <returns>The created kernel.</returns>
      52             :                 private static IKernel CreateKernel()
      53             :                 {
      54             :                         return new WebApiStartUp(new ConfigurationManager()).CreateKernel();
      55             :                 }
      56             : 
      57             :                 private class WebApiStartUp : SimplifiedNinjectStartUp<WebApiModule>
      58             :                 {
      59             :                         /// <summary>
      60             :                         /// Instantiate a new instance of <see cref="WebApiStartUp"/>
      61             :                         /// </summary>
      62           1 :                         public WebApiStartUp(IConfigurationManager configurationManager)
      63             :                                 : base(configurationManager)
      64             :                         {
      65             :                         }
      66             : 
      67             :                         #region Overrides of SimplifiedNinjectStartUp<WebHostModule>
      68             : 
      69             :                         /// <summary>
      70             :                         /// Adds the <see cref="SimplifiedSqlModule{TAuthenticationToken}"/> into <see cref="NinjectDependencyResolver.ModulesToLoad"/>.
      71             :                         /// </summary>
      72           1 :                         protected override void AddSupplementryModules()
      73             :                         {
      74             :                                 NinjectDependencyResolver.ModulesToLoad.Insert(2, new SimplifiedSqlModule<SingleSignOnToken>());
      75             :                         }
      76             : 
      77             :                         #endregion
      78             :                 }
      79             :         }
      80             : }

Generated by: LCOV version 1.10