Last active
August 29, 2015 14:17
-
-
Save gon250/da17337ff857688a54b2 to your computer and use it in GitHub Desktop.
Revisions
-
remojansen renamed this gist
Mar 13, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
remojansen revised this gist
Mar 13, 2015 . 2 changed files with 49 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ public class HttpDependencyResolver : IDependencyResolver { private readonly IResolutionRoot _resolutionRoot; public HttpDependencyResolver(IResolutionRoot kernel) { this._resolutionRoot = kernel; } public object GetService(Type serviceType) { return _resolutionRoot.TryGet(serviceType); } public IEnumerable<object> GetServices(Type serviceType) { return _resolutionRoot.GetAll(serviceType); } public IDependencyScope BeginScope() { // This example does not support child scopes, so we simply return 'this'. return this; } public void Dispose() { // When BeginScope returns 'this', the Dispose method must be a no-op. } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ public class MvcDependencyResolver : IDependencyResolver { private readonly IResolutionRoot _resolutionRoot; public MvcDependencyResolver(IResolutionRoot kernel) { this._resolutionRoot = kernel; } public object GetService(Type serviceType) { return _resolutionRoot.TryGet(serviceType); } public IEnumerable<object> GetServices(Type serviceType) { return _resolutionRoot.GetAll(serviceType); } } -
remojansen revised this gist
Mar 3, 2015 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,3 @@ namespace Solution.CMS { public class MvcApplication : System.Web.HttpApplication -
remojansen revised this gist
Mar 3, 2015 . 2 changed files with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ namespace Solution.IoC { public class DependencyInjectionProvider { This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ using System; using System.Collections.Generic; using System.Linq; @@ -7,7 +6,7 @@ using System.Web.Mvc; using System.Web.Routing; namespace Solution.CMS { public class MvcApplication : System.Web.HttpApplication { -
remojansen revised this gist
Mar 3, 2015 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,3 @@ namespace MMWebsites.IoC { public class DependencyInjectionProvider -
remojansen revised this gist
Feb 27, 2015 . No changes.There are no files selected for viewing
-
remojansen created this gist
Feb 27, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ using Ninject; using MMWebsites.DAL.Helpers; using MMWebsites.DAL.Repository; using MMWebsites.Global.Contracts; using MMWebsites.Global.Helpers; namespace MMWebsites.IoC { public class DependencyInjectionProvider { private IKernel _kernel; private void SetUpDependencyInjection() { //create _kernel _kernel = new StandardKernel(); //bindings _kernel.Bind<IJsDateHelper>().To<JsDateHelper>(); _kernel.Bind<IDbHelper>().To<DbHelper>(); _kernel.Bind<IUserRepository>().To<UserRepository>(); _kernel.Bind<ISiteRepository>().To<SiteRepository>(); _kernel.Bind<IClientDetailsRepository>().To<ClientDetailsRepository>(); _kernel.Bind<IFileDetailsRepository>().To<FileDetailsRepository>(); _kernel.Bind<IPublicationRepository>().To<PublicationRepository>(); } public T Resolve<T>(System.Type service) { return (T)_kernel.Get(service); } public void Dispose() { _kernel.Dispose(); } public System.Web.Mvc.IDependencyResolver GetMvcDependencyResolver() { SetUpDependencyInjection(); return new MvcDependencyResolver(_kernel); } public System.Web.Http.Dependencies.IDependencyResolver GetHttpDependencyResolver() { SetUpDependencyInjection(); return new HttpDependencyResolver(_kernel); } } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ using MMWebsites.IoC; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Web.Routing; namespace MMWebsites.CMS { public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); var dependencyInjectionProvider = new DependencyInjectionProvider(); // Set MVC depencendy resolver for asp mvc web project DependencyResolver.SetResolver(dependencyInjectionProvider.GetMvcDependencyResolver()); // Set MVC depencendy resolver for asp mvc web API project GlobalConfiguration.Configuration.DependencyResolver = dependencyInjectionProvider.GetHttpDependencyResolver(); // Remove the XM Formatter from the web api GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); } } }