DevTeam / Pure.DI

Pure DI for .NET without frameworks!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to register composition roots with fewer API calls

NikolayPianikov opened this issue · comments

Right now:

DI.Setup(nameof(Composition))
  .Bind<IService>().To<Service>()
  .Bind<IService>("Other").To<OtherService>()
  .Root<IService>("MyRoot")
  .Root<IService>("SomeOtherService", "Other");

An API such as this is proposed:

DI.Setup(nameof(Composition))
  .RootBind<IService>("MyRoot").To<Service>()
  .RootBind<IService>("SomeOtherService", "Other").To<OtherService>()

Thus we could add a new API method to IConfiguration like:

IBinding RootBind<T>(string name = "", object tag = null, RootKinds kind = RootKinds.Default);

For integration tests and local debugging, you can use this project.

Major changes are likely to be here.

We also need an example in the documentation. It can be done here.