NanoIoC 2.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package NanoIoC --version 2.0.5                
NuGet\Install-Package NanoIoC -Version 2.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NanoIoC" Version="2.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NanoIoC --version 2.0.5                
#r "nuget: NanoIoC, 2.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NanoIoC as a Cake Addin
#addin nuget:?package=NanoIoC&version=2.0.5

// Install NanoIoC as a Cake Tool
#tool nuget:?package=NanoIoC&version=2.0.5                

NanoIoC

A tiny IoC container, does exactly what you want, and only that.

Getting Started

Container.Global is a static instance of IContainer. You can use this as your entry point.

Manually Registering Dependencies

Use either of these methods:

<pre> void IContainer.Register<TAbstract, TConcrete>(Lifecycle lifecycle = Lifecycle.Singleton); void IContainer.Register(Type abstract, Type concrete, Lifecycle lifecycle = Lifecycle.Singleton); </pre>

You will typically want to put your registrations inside an IContainerRegistry.

NanoIoC will find all IContainerRegistrys in all assemblies in the application's base directory (excluding those that start with the System namespace)

To run all the registries, use:

<pre> void IContainer.RunAllRegistries(); </pre>

Auto Registering Dependencies

You can create TypeProcessors that scan all types allowing you to auto-wire them up.

NanoIoC will find all TypeProcesors in all assemblies in the application's base directory (excluding those that start with the System namespace)

For example:

<pre> void IContainer.RunAllTypeProcessors(); </pre>

Where one of your TypeProcessors might look like: <pre> public class ExampleTypeProcessor : ITypeProcessor { public void Process(Type type, IContainer container) { if(typeof(MyInterface).IsAssignableFrom(type) && type != typeof(MyInterface)) container.Register(typeof(MyInterface), type, Lifecycle.Singleton); } } </pre>

Resolving Dependencies:

Use either of these methods:

<pre> T IContainer.Resolve<T>(); object IContainer.Resolve(Type type); </pre>

You can resolve concrete types that aren't registered, as long as all their dependencies are registered or directly constructable.

You can get all registered types: <pre> IEnumerable<T> IContainer.ResolveAll<T>() IEnumerable IContainer.ResolveAll(Type type); </pre>

Injecting instances:

You can inject existing instances:

<pre> void IContainer.Inject<T>(T instance, Lifecycle lifeCycle = Lifecycle.Singleton); void IContainer.Inject(object instance, Type type, Lifecycle lifecycle); </pre>

Product Compatible and additional computed target framework versions.
.NET Framework net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on NanoIoC:

Package Downloads
MustardBlack.Hosting.AspNet

MustardBlack.Hosting.AspNet library.

MustardBlack.ViewEngines.Razor

MustardBlack.ViewEngines.Razor library.

MustardBlack.Hosting.AspNetCore

MustardBlack.Hosting.AspNetCore library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.5.43 12,490 7/26/2019
2.5.38 2,046 4/17/2019
2.5.37 652 4/16/2019
2.5.36 661 4/16/2019
2.5.35 677 4/16/2019
2.4.34 686 4/16/2019
2.4.33 679 4/9/2019
2.4.32 671 4/9/2019
2.4.31 694 2/21/2019
2.3.30-prerelease 547 2/21/2019
2.3.29-prerelease 592 2/20/2019
2.3.28-prerelease 915 2/18/2019
2.3.26-prerelease 578 2/15/2019
2.2.24 755 2/11/2019
2.2.23 828 1/30/2019
2.2.20 736 1/30/2019
2.2.19 784 1/22/2019
2.1.9 823 11/14/2018
2.1.7 956 10/1/2018
2.1.6 984 8/10/2018
2.1.0 1,166 7/11/2018
2.0.5 1,272 6/27/2018
2.0.4 62,607 7/30/2018