Created
October 22, 2012 21:27
-
-
Save rsleggett/3934512 to your computer and use it in GitHub Desktop.
Here's a ninject dependency resolver
This file contains 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 characters
namespace DD4T.Web.Mvc.Ninject | |
{ | |
///<summary> | |
/// NinjectDependencyResolver | |
/// 2012-10-22 | |
/// Author: Robert Stevenson-Leggett | |
///</summary> | |
public class NinjectDependencyResolver : IDependencyResolver | |
{ | |
private readonly IKernel _kernel; | |
public NinjectDependencyResolver(IKernel kernel) | |
{ | |
_kernel = kernel; | |
} | |
public object GetService(Type serviceType) | |
{ | |
return _kernel.TryGet(serviceType); | |
} | |
public IEnumerable<object> GetServices(Type serviceType) | |
{ | |
return _kernel.GetAll(serviceType); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment