1. maksim volkau
  2. DryIoc

Wiki

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 DryIoc.

How to instantiate SomeClient with DI principle in mind:

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

That's hard-wired!

How to do that with DryIoc:

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

    // somewhere else
    IClient 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 client interface.

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

So IoC container helps me to enforce Open-Closed principle and to improve Testability and Extensibility of my software.

Usage 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

v2.11.6 / 2017-07-18

  • fixed: #495: InvalidCastException on type resolution

v2.11.5 / 2017-07-12

  • fixed (!!!): #493 Some resolving of the controller ends up with exception "Container is disposed..."
  • fixed: #175 Deterministic implicit rule to select from multiple services for specific scope

v2.11.4 / 2017-06-27

  • fixed: #488 DryIoc.ContainerException if using WithDependencies

v2.11.3 / 2017-06-01

  • fixed: Backward compatibility of DryIoc 2.11 WrapperSetup.Condition with 2.10

v2.11.2 / 2017-06-01

  • fixed: Backward compatibility of DryIoc 2.11 Setup.Condition with 2.10
  • fixed: #480: DryIoc.Microsoft.DependencyInjection - WithDependencyInjectionAdapter() exception

v2.11.1 / 2017-05-31

  • fixed: UseInstance is not backward compatible with v2.10
  • fixed: #478: DryIoc.Owin.dll 2.2.0 not compatible with DryIoc.dll 2.11.0

v2.11.0 / 2017-05-30

  • added: #449: Provide a way to log unresolved dependencies via Rules.WithUnknownServiceHandler
  • added: #463: Add IfAlreadyRegistered option for UseInstance
  • added: #475: Dynamic Registration Providers to enable lazy and on-demand registrations
  • added: #476: AutoFallback and AutoConcreteType resolution based on Dynamic Registration providers
  • fixed: #396: Enable ResolveMany to use auto fallback resolution via dynamic registrations
  • fixed: #451: DryIoc should know about static members
  • fixed: #474: Exclude supported collection wrapper interfaces from RegisterMany / ExportMany
  • fixed: #477: ArgumentException while resolving
  • fixed: DryIocAttributes dependency to System.Diagnostics.Tools from ..Debug

Previous Versions

Updated