Skip to content

robinmaben/ObjectMap

Repository files navigation

ObjectMap

ObjectMap is a simple IoC container for .NET.

Build Status

NuGet version

It started out as a practice exercise and an excuse to try out features of the C# 6 preview.

Key Features -

  1. Auto-inject constructor dependencies
  2. Auto-inject property dependencies
  3. Supports lazy instantiation
  4. Lifecycle options Singleton, PerRequest (default being LastCreated)
  5. Handles Cyclic Dependencies

Simple (although contrived) usage examples -

ObjectMap.Register<ILogFormat, LogFormat>();

ObjectMap.Register<ILogSettings>(new LogSettings());

ObjectMap.Register<ILogFile>(() => new LogFile()); //Lazy

ObjectMap.Register<ILogger, Logger>().Singleton(); //default lifecycle option is .LastCreated()

ObjectMap.Register<ILogger, Logger>().PerRequest();

public class Logger : ILogger
{
    public Logger(ILogSettings logSettings)
    {
        
    }
    
    ILogFormat LogFormat{ get; set; }
}

public class LogSettings : ILogSettings
{
    ILogFile LogFile { get; set; }
}

About

ObjectMap - A lightweight IoC container for .NET

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages