Created
March 18, 2014 02:27
-
-
Save gyuwon/9612507 to your computer and use it in GitHub Desktop.
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 characters
public class NinjectDependencyScope : IDependencyScope | |
{ | |
private IKernel _kernel; | |
public NinjectDependencyScope(IKernel kernel) | |
{ | |
Contract.Assert(kernel != null); | |
this._kernel = kernel; | |
} | |
public object GetService(Type serviceType) | |
{ | |
return this._kernel.TryGet(serviceType); | |
} | |
public IEnumerable<object> GetServices(Type serviceType) | |
{ | |
return this._kernel.GetAll(serviceType); | |
} | |
public void Dispose() | |
{ | |
this._kernel = null; | |
} | |
} | |
public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver | |
{ | |
private IKernel _kernel; | |
public NinjectDependencyResolver(IKernel kernel) | |
: base(kernel) | |
{ | |
this._kernel = kernel; | |
} | |
public IDependencyScope BeginScope() | |
{ | |
return new NinjectDependencyScope(this._kernel); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment