Skip to content
This repository

Convention based binding for Ninject

Octocat-spinner-32 lib Added support for the factory extension December 21, 2011
Octocat-spinner-32 nuget Added assembly description for nuget December 28, 2011
Octocat-spinner-32 src Added the feature that multiple configurations can be done in one Bin… March 19, 2014
Octocat-spinner-32 tools Update NAnt config for Windows 8 March 20, 2014
Octocat-spinner-32 .gitignore Added assembly description for nuget December 28, 2011
Octocat-spinner-32 HowToBuild.txt Updated How to Build - Reference teamcity.bbv.ch instead of codebetter January 10, 2014
Octocat-spinner-32 LICENSE.txt Adding project files from ninject fork. August 27, 2009
Octocat-spinner-32 Ninject.Extensions.Conventions - With SL and WP7 Unittests.sln Added the feature that multiple configurations can be done in one Bin… March 19, 2014
Octocat-spinner-32 Ninject.Extensions.Conventions.build Updated Build Scripts to support pull request builds on TeamCity March 19, 2014
Octocat-spinner-32 Ninject.Extensions.Conventions.sln Added the feature that multiple configurations can be done in one Bin… March 19, 2014
Octocat-spinner-32 Ninject.Extensions.Conventions.sln.docstates Added the feature that multiple configurations can be done in one Bin… March 19, 2014
Octocat-spinner-32 Ninject.build Revert "Changed the build scripts that WP7 Uni Tests are not executed… March 20, 2014
Octocat-spinner-32 Ninject.include Fixed build script that version is not changed during dependency vers… March 20, 2014
Octocat-spinner-32 README.markdown Update README.markdown February 19, 2013
Octocat-spinner-32 ReleaseNotes.txt Update release notes March 21, 2014
Octocat-spinner-32 UnzipDependencies.cmd Improved Build scripts to allow the creation of zip files with a spec… December 06, 2010
Octocat-spinner-32 build-alpha.cmd Updated to Nuget 1.6 and added support for prerelease packages December 23, 2011
Octocat-spinner-32 build-beta.cmd Updated to Nuget 1.6 and added support for prerelease packages December 23, 2011
Octocat-spinner-32 build-rc1.cmd Updated to Nuget 1.6 and added support for prerelease packages December 23, 2011
Octocat-spinner-32 build-release.cmd Updated to NuGet 1.3 May 03, 2011
Octocat-spinner-32 build.cmd Updated to the common build script files October 17, 2010
README.markdown

Installation

To install from the Package Manager Console, just type the following:

Install-Package Ninject.extensions.conventions

Sample uses

Binding default single interface

IKernel kernel = new StandardKernel();

kernel.Bind(x =>
    {
        x.FromThisAssembly() // Scans currently assembly
         .SelectAllClasses() // Retrieve all non-abstract classes
         .BindDefaultInterface() // Binds the default interface to them;
    });

Default interface in this scenario means that if your interface is named IService, then the class named Service will be binded to it. However, the class SqlBasedService will not be binded and will fail to retrieve the implementation.

Binding single interface

IKernel kernel = new StandardKernel();

kernel.Bind(x =>
    {
        x.FromThisAssembly() // Scans currently assembly
         .SelectAllClasses() // Retrieve all non-abstract classes
         .BindSingleInterface() // Binds the default interface to them;
    });

Binding single interface means that you are expecting to have one implementation per classes found. This would bind SqlBasedService to IService as well as Service to IService but would not bind SqlBasedService and Service to an IService.

Something went wrong with that request. Please try again.