ObjectMap is a simple IoC container for .NET.
It started out as a practice exercise and an excuse to try out features of the C# 6 preview.
Key Features -
- Auto-inject constructor dependencies
- Auto-inject property dependencies
- Supports lazy instantiation
- Lifecycle options Singleton, PerRequest (default being LastCreated)
- 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; }
}