-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Ninject adapter - Support some simplified connector registration cases - Add tests for ninject adapter - Support tail calls into the same machine in entry actions - Add test for tail call support
- Loading branch information
Ovan Crone
committed
Feb 13, 2018
1 parent
029862e
commit cec2c77
Showing
34 changed files
with
616 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Linq; | ||
using Ninject; | ||
using Ninject.Activation; | ||
|
||
namespace REstate.IoC.Ninject | ||
{ | ||
public class NinjectComponentContainer | ||
: IComponentContainer | ||
{ | ||
public NinjectComponentContainer(IKernel kernel) | ||
{ | ||
Kernel = kernel; | ||
} | ||
|
||
protected IKernel Kernel { get; } | ||
|
||
public void Register<T>(T instance, string name = null) where T : class | ||
{ | ||
var binding = Kernel.Bind<T>().ToConstant(instance); | ||
|
||
if(name is null) | ||
return; | ||
|
||
binding.Named(name); | ||
} | ||
|
||
public void Register(Type registrationType, Type implementationType, string name = null) | ||
{ | ||
var binding = Kernel.Bind(registrationType).To(implementationType); | ||
|
||
if(name is null) | ||
return; | ||
|
||
binding.Named(name); | ||
} | ||
|
||
public void Register<T>(FactoryMethod<T> resolver, string name = null) where T : class | ||
{ | ||
T Resolve(IContext context) => resolver(this); | ||
|
||
var binding = Kernel.Bind<T>().ToMethod(Resolve); | ||
|
||
if(name is null) | ||
return; | ||
|
||
binding.Named(name); | ||
} | ||
|
||
public void RegisterComponent(IComponent component) | ||
{ | ||
component.Register(this); | ||
} | ||
|
||
public T Resolve<T>(string name = null) where T : class | ||
=> name is null ? Kernel.Get<T>() : Kernel.Get<T>(name); | ||
|
||
public T[] ResolveAll<T>() where T : class => | ||
Kernel.GetAll<T>().ToArray(); | ||
|
||
void IRegistrar.Register<TBinding, TImplementation>(string name) | ||
{ | ||
var binding = Kernel.Bind<TBinding>().To<TImplementation>(); | ||
|
||
if(name is null) | ||
return; | ||
|
||
binding.Named(name); | ||
} | ||
} | ||
} |
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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks> | ||
<Authors>Ovan Crone</Authors> | ||
<Company>Psibernetic Solutions</Company> | ||
<Description>Ninject adapter for REstate.</Description> | ||
<Copyright>Ovan Crone 2016</Copyright> | ||
<PackageLicenseUrl>https://github.com/psibr/REstate/blob/v6.0/LICENSE</PackageLicenseUrl> | ||
<Version>3.0.0</Version> | ||
<AssemblyVersion>3.0.0.0</AssemblyVersion> | ||
<FileVersion>3.0.0.0</FileVersion> | ||
<LangVersion>latest</LangVersion> | ||
<PackageProjectUrl>https://github.com/psibr/REstate</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/psibr/REstate</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageTags>REstate</PackageTags> | ||
<PackageIconUrl>https://github.com/psibr/REstate/blob/master/assets/icons/REstate-64.png?raw=true</PackageIconUrl> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Ninject" Version="3.3.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\src\REstate\REstate.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
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
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
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,13 @@ | ||
namespace REstate.Engine.Connectors | ||
{ | ||
public class ConnectorConfiguration | ||
: IConnectorConfiguration | ||
{ | ||
public ConnectorConfiguration(string identifier) | ||
{ | ||
Identifier = identifier; | ||
} | ||
|
||
public string Identifier { get; } | ||
} | ||
} |
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
Oops, something went wrong.