This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Ninject to keep and resolve aspects from container.
- Loading branch information
Showing
5 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Practices.ServiceLocation; | ||
using Ninject; | ||
|
||
namespace Snap.Ninject | ||
{ | ||
/// <summary> | ||
/// This is common service locator adapter for Ninject IoC container | ||
/// </summary> | ||
/// <remarks> | ||
/// Cannot use existing adapter from NInjectAdapter library distributed within CommonServiceLocator.NInjectAdapter NuGet package. | ||
/// Existing NinjectAdapter is build for NET4.0 runtime. | ||
/// </remarks> | ||
public class NinjectServiceLocatorAdapter : ServiceLocatorImplBase | ||
{ | ||
private readonly IKernel _kernel; | ||
|
||
public NinjectServiceLocatorAdapter(IKernel kernel) | ||
{ | ||
_kernel = kernel; | ||
} | ||
|
||
protected override object DoGetInstance(Type serviceType, string key) | ||
{ | ||
return _kernel.Get(serviceType); | ||
} | ||
|
||
protected override IEnumerable<object> DoGetAllInstances(Type serviceType) | ||
{ | ||
return _kernel.GetAll(serviceType); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Castle.Core" version="2.5.2" /> | ||
<package id="CommonServiceLocator" version="1.0" /> | ||
<package id="Ninject" version="2.2.1.4" /> | ||
</packages> |
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