Project Description
IInject is a DI (Dependency Injection / IoC Container) framework that is very light weight, fast, and easy to use. It is written in C# and .NET 4.0.

NuGet Packages:
IInject
http://nuget.org/packages/IInject
PM> Install-Package IInject

IInject.CommonServiceLocator
http://nuget.org/packages/IInject.CommonServiceLocator
PM> Install-Package IInject.CommonServiceLocator

NEW to IInject

Assembly scanning.
var container = new Container();
ScanRules.Current.Clear();
ScanRules.Current.Add(ScanningRule.Inherits<System.Web.Mvc.Controller>());
ScanRules.Current.Add(ScanningRule.Implements<System.Web.Mvc.IActionFilter>());
container.Scan(a => a.Scan("SomeAssembly.dll"));
var container = new Container();
container.Scan(a =>
{
	a.Add(ScanningRule.InterfaceNamingDefault());
	a.Add(ScanningRule.PublicClass());
	a.ScanCallingAssembly();
});

Diagnostics: Add reference IInject.Diagnostics.dll
using IInject.Diagnostics;
var diagnostics = container.RunSelfDiagnostics();
--------------IInject.Container Self Diagnostics--------------

RegistryType: DefaultContextRegistry, ItemsRegistered: 1

Key: null
Scope: PerResolve
FromTypeName: IInject.Tests.IDependencyTest
ToTypeName: IInject.Tests.DependencyTest
Instance: null
PropertiesToInject: 0

RegistryType: KeyedContextRegistry, ItemsRegistered: 0

RegistryType: EnumerableContextRegistry, ItemsRegistered: 0

RegistryType: KeyedEnumerableContextRegistry, ItemsRegistered: 0

using IInject.Diagnostics;
var resolveDiagnostics = container.RunResolveAllSelfDiagnostics();
--------------IInject.Container ResolveAll Self Diagnostics--------------
Can't resolve a constructor for type: 'IInject.Tests.InjectedProperty'.


IInject Features:
  • Constructor injection
    • Selects the constructor with the most parameters it can satisfy
  • Property injection
    • Registering properties to be injected.
    • Example #1
    • No need to have attributes on properties, so, the only project that needs to reference IInject is the one doing the registering of the types.
  • It's fast, very fast
    • 1,000,000 PerResolve Gets took 25.0400150s (1 = 0.000025040015s) (Creates a new instance each time it's resolved)
    • 1,000,000 Singleton Gets took 1.9629935s (1 = 0.0000019629935s) (Uses the instance provided or creates a new instance the first time and uses that instance each additional time it's resolved)
  • Light weight and very easy to use.
  • Fluent interface
    • Example #2
  • Still in heavy development with lots of things to come.
  • Comes with an Adapter for Common Service Locator
#1
container.Map<MyDependency>(m => m.Inject(t => t.Name)); 
#2
var test = container.Set<DependencyTest>().Set<Dependent>().Get<DependencyTest>();

Still working on all the xml-documentation comments, sorry guys. (I hate that part)

Check out the current release here and let me know what you think. If you like it, please tell your friends.. Also, check out my blog LogikBug.com

Here is a speed test with most of the popular DI Frameworks. Each container does 1,000,000 resolves of an object that contains 2 constructor dependencies.
TestResults.jpg

Last edited Dec 21, 2012 at 11:42 PM by sbaker, version 35