MyMemorySucks Inversion of Control/Dependency Injection Container

Recently I discovered the inversion of control/dependency injection pattern and love the level of decoupling it introduces. For those that have not yet been introduced to the delights of this design pattern there’s a fantastic article on Martin Fowler’s site.

To provide a quick overview, the IoC/DI pattern centres around the premise that rather than having to explicitly instantiate core objects a local service does it for you. By doing this you can minimise dependencies between concrete types. This makes the IoC/DI patterns particularly useful for separating fundamentally different sections of an application such as the UI and the business logic. By only ever using interface declarations within the UI, the implementations for the business logic are ‘injected’ by an IoC/DI container service can be easily switched out with test classes.

Now there are few feature packed IoC/DI MS.NET based frameworks available but they all involve referencing foreign assemblies into your project. This isn’t a major problem for most but I’m not really wanting to have to reference and distribute any foreign assemblies with my software so I’ve decided to make an attempt at writing my own in C# which you can download from this page. I’ve written this container to work with .NET Framework 2.0.

I’ve set up this page for any comments anybody has on the container I’ve written and I welcome all feedback. Would also be great to hear from you if you have used it and found it helpful. I’ll post any updates I make to the container on this page. As far as licensing is concerned, this is a public domain Inversion of Control container / Dependency Injection container so you can do as you please with it.

You can download the source from my Beanstalk Subversion account or you can download a specific release from the list of releases below.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

[2009.08.02] 0.1 Alpha – This is a very first release of the container with very minimal testing and no documentation only a very brief example. This first release allows you to register classes and specific constructors to use. If a class is not registered the IoCContainer class will attempt to use the default constructor to instantiate an object of the requested type.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s