Skip to content

Using Ninject with REstate

Ovan Crone edited this page Apr 11, 2018 · 2 revisions

Adding the Ninject adapter to your project

Install the nuget package

The adapter is available in a nuget package: REstate.IoC.Ninject

Instantiate the adapter

var yourNinjectKernel = new StanardKernel(); // Replace with your kernel.

var restateNinjectContainer = new NinjectComponentContainer(yourNinjectKernel);

Use Ninject for the default Host

At application startup, add the following line, building on the last snippet.

REstateHost.UseContainer(restateNinjectContainer);

Use Ninject in individual Hosts

Some scenarios don't lend well to using a shared instance of REstateHost, such as if you have scoped kernels, or if you plan to inject REstateHost as a dependency. This is also supported and is honestly even easier.

Whenever you need a host, just instantiate it with the REstate Container you made before.

var host = new REstateHost(restateNinjectContainer);