Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web.Mvc;
  4. using Ninject;
  5. using SlateCore.BLL.Interfaces;
  6. using SlateCore.BLL.Services;
  7. using SlateCORE.Web.Helpers;
  8. using SlateCORE.Web.Interfaces;
  9.  
  10. namespace SlateCORE.Web.Util
  11. {
  12.     /// <summary>
  13.     ///
  14.     /// </summary>
  15.     public class NinjectDependencyResolver : IDependencyResolver
  16.     {
  17.         private IKernel _kernel;
  18.  
  19.         public NinjectDependencyResolver(IKernel kernelParam)
  20.         {
  21.             _kernel = kernelParam;
  22.             AddBindings();
  23.         }
  24.  
  25.  
  26.         private void AddBindings()
  27.         {
  28.             _kernel.Bind<IAccountService>().To<AccountService>();
  29.             _kernel.Bind<ISessionService>().To<SessionService>();
  30.             _kernel.Bind<IFormsAuthenticationService>().To<FormsAuthenticationService>();
  31.             _kernel.Bind<IBookService>().To<BookService>();
  32.             _kernel.Bind<IBookmarkService>().To<BookmarkService>();
  33.             _kernel.Bind<ILibraryService>().To<LibraryService>();
  34.             _kernel.Bind<IHistoryService>().To<HistoryService>();
  35.             _kernel.Bind<IRecommendationService>().To<RecommendationService>();
  36.             _kernel.Bind<ITestService>().To<TestService>();
  37.             _kernel.Bind<ISectionService>().To<SectionService>();
  38.             _kernel.Bind<IGenreService>().To<GenreService>();
  39.         }
  40.  
  41.  
  42.         public object GetService(Type serviceType)
  43.         {
  44.             return _kernel.TryGet(serviceType);
  45.         }
  46.  
  47.  
  48.         public IEnumerable<object> GetServices(Type serviceType)
  49.         {
  50.             return _kernel.GetAll(serviceType);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement