Last night, while hacking on the Aggressive project, I where in the need of a container. My initial idea was to try out Autofac, but since I was offline at the moment, I quickly hacked together a small container myself. Since I actually thought the look&feel of the interface was exactly what I wanted, I decided to put the source code in a separate project and give it a name; Tinyject. The code can be found here and is licensed under  the Apache License 2.0.

Features:

  • A Register() method in different flavors (including generic versions) for registering concrete types & interfaces in the type map.
    The Register() methods return this, so they can be chained.
  • A Resolve() method in different flavors (including generic versions) for resolving new and existing instances of registered types.
  • An idea of instance lifetime; Transient & Singleton.
  • Property, field and constructor injection.
  • The container implements System.IDisposable, and can be used in a using() { … } scope.
  • A static, thread-safe wrapper, TinyjectStatic.
  • A small number of xUnit-based unit tests to check the integrity of the stuff.

That’s it. At the moment there is no configuration system – and no extensibility points, but I believe the 2.0 version – maybe developed tonight after the baby swimming, will contain a simple extensible configuration model.

If anyone want to design a logo for it – please go ahead :-)

kick it on DotNetKicks.com

2 Trackbacks/Pingbacks

  1. [...] Tinyject – IoC in an Evening - Lars Wilhelmsen had a need for a simple IOC container, so crafted a simple implementation in an evening. Lars hints at a version 2, and I look forward to seeing how this project progresses. [...]

  2. By Weekly Links #23 | GrantPalin.com on 19 Oct 2008 at 8:53 pm

    [...] Tinyject – IoC in an Evening Wow. Something so seemingly complex done in just a few hours. [...]

Post a Comment

You must be logged in to post a comment.