Skip to content

Is it possible to create an object with parameters for each Resolve in a dependency registered in transient? #30

Discussion options

You must be logged in to vote

I have published a beta package and added the RootArg method. Please see the example here. Now you can create composition roots with arguments. And your example can be rewritten like this:

using Pure.DI;

var composition = new Composition();

var service1 = composition.CreateService(param1: "ABC", param2: 123);            // <---(A)
var service2 = composition.CreateService(param1: "XYZ", param2: 789);            // <---(B)

DI.Setup("Composition")
    .Bind<IDependency>().To<Dependency>()
    .RootArg<string>("param1")
    .RootArg<int>("param2")
    .Bind<IService>().To<Service>().Root<IService>("CreateService");

interface IDependency { }

class Dependency : IDependency { }

interface I…

Replies: 13 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by NikolayPianikov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@NikolayPianikov
Comment options

Comment options

You must be logged in to vote
5 replies
@NikolayPianikov
Comment options

@NikolayPianikov
Comment options

@YoshihiroIto
Comment options

@NikolayPianikov
Comment options

@YoshihiroIto
Comment options

Comment options

You must be logged in to vote
1 reply
@YoshihiroIto
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants