Skip to content
Convention based binding for Ninject
C# Batchfile
Latest commit d0f2acc Jul 30, 2015 @scott-xu scott-xu Merge pull request #23 from regisbsb/patch-1
Update README.md
Failed to load latest commit information.
lib Added support for the factory extension Dec 21, 2011
nuget Update release notes and nuget spec Nov 2, 2014
src Fix doc comment typos Dec 19, 2014
tools Updated build script to mono 3.4 Apr 25, 2014
.gitignore Added assembly description for nuget Dec 28, 2011
HowToBuild.txt Updated How to Build - Reference teamcity.bbv.ch instead of codebetter Jan 10, 2014
LICENSE.txt Adding project files from ninject fork. Aug 27, 2009
Ninject.Extensions.Conventions - With SL and WP7 Unittests.sln Added the feature that multiple configurations can be done in one Bin… Mar 19, 2014
Ninject.Extensions.Conventions.build Added mono settings to test compilation. Apr 25, 2014
Ninject.Extensions.Conventions.sln Update ReleaseNotes Oct 26, 2014
Ninject.Extensions.Conventions.sln.docstates Added the feature that multiple configurations can be done in one Bin… Mar 19, 2014
Ninject.build Revert "Changed the build scripts that WP7 Uni Tests are not executed… Mar 20, 2014
Ninject.include Updated build script to mono 3.4 Apr 25, 2014
README.md Update README.md Jul 30, 2015
ReleaseNotes.md Update ReleaseNotes Oct 26, 2014
UnzipDependencies.cmd Improved Build scripts to allow the creation of zip files with a spec… Dec 6, 2010
build-alpha.cmd Updated to Nuget 1.6 and added support for prerelease packages Dec 23, 2011
build-beta.cmd Updated to Nuget 1.6 and added support for prerelease packages Dec 22, 2011
build-rc1.cmd Updated to Nuget 1.6 and added support for prerelease packages Dec 22, 2011
build-release.cmd Updated to NuGet 1.3 May 3, 2011
build.cmd Updated to the common build script files Oct 17, 2010

README.md

Ninject.Extensions.Conventions NuGet Version NuGet Downloads

Provides a configuration by convention extension for Ninject.

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.

You can find more details in wiki page.

CI build status

Build Status

Something went wrong with that request. Please try again.