Adds support for role injection
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 3 commits behind ninject:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
nuget
src
tools
.gitignore
HowToBuild.txt
LICENSE.txt
Ninject.Extensions.Azure.build
Ninject.Extensions.Azure.sln
Ninject.build
Ninject.include
ReleaseNotes.txt
Settings.StyleCop
UnzipDependencies.cmd
build-alpha.cmd
build-beta.cmd
build-rc1.cmd
build-release.cmd
readme.md

readme.md

Getting Started

Introduction

This extension adds support for Microsoft Azure Worker Roles.

Just derive from NinjectRoleEntryPoint in your WorkerRole.cs (previously RoleEntryPoint) and override the following methods:

The Run method is the main thread of execution for your role instance.

public abstract override void Run();

Implement the CreateKernel method to create and configure your kernel and load the modules required by your role instance.

protected abstract IKernel CreateKernel();

If you like to extend the startup behavior of your role instance just override OnRoleStarted() which is called after CreateKernel.

protected virtual bool OnRoleStarted();

If you like to extend the shutdown behavior of your role instance you have two choices. You can override OnRoleStopping() which is called before the kernel is disposed.

protected virtual void OnRoleStopping();

Addition to that you can also override OnRoleStopped() which is called after the kernel is disposed.

protected virtual void OnRoleStopped();

Example file

using System;
using Ninject;
using Ninject.Extensions.Azure;

namespace Example
{

    public class MyRoleEntryPoint : NinjectRoleEntryPoint
    {

        public override void Run()
        {

        }

        protected override IKernel CreateKernel()
        {
            return new StandardKernel();
        }

        protected override bool OnRoleStarted()
        {
            return true;
        }

        protected override void OnRoleStopping()
        {

        }

        protected override void OnRoleStopped()
        {

        }
    }

}