Clone wiki

DryIoc / Home

Wiki Home

Getting Started

Starting from simple interface/implementation setup:

public interface IService { }
public class SomeService : IService { }

public interface IClient { IService Service { get; } }
public class SomeClient : IClient
{
    public IService Service { get; private set; }
    public SomeClient(IService service) { Service = service; }
}

Let's compare creation of SomeClient manually and with help of DryIoc.

How to instantiate SomeClient with DI principle in mind:

IClient client = new SomeClient(new SomeService());

That's hard-wired implementation. Let's try do it with DryIoc:

var c = new Container();
c.Register<IClient, SomeClient>();
c.Register<IService, SomeService>();

// somewhere else
var client = c.Resolve<IClient>();

In DryIoc we are declaring/registering mapping between interfaces and implementations. Then in different space and time we are deciding to get/resolve IClient object with its dependencies by providing only the client interface.

Hey, it means that I can register different IClient implementations without touching consumer resolution code. And we are not speaking about other goodies yet.

As a result, IoC container is the tool to enforce Open-Closed principle and to improve Testability and Extensibility of my software.

User's Guide

Companions

Extensions

Samples

Located in this repo:

External links:

Latest Version

Get from NuGet:

  • DryIoc.dll NuGet Badge
  • DryIoc (source code) NuGet Badge
  • DryIoc.Internal (source code with public types made internal) NuGet Badge

v3.1.0 / soon

Stay tuned!

v3.0.0 / 2018-06-24

Release Notes

Previous Versions

Updated