3

I have a container implemented in unity 2.0 and DI.
I have a singleton factory class that i register in the container.
How can I register it if one of its constructor parameters are IContainer ?
What is the technique to do so ? To register singelton object that consumes the container in the constructor.

Thanks

1
  • I would be surprised if that was supported. Commented Mar 28, 2013 at 6:25

1 Answer 1

2

You can simply register the container into itself:

container.RegisterInstance<IUnityContainer>(container);

Note however that you should ONLY inject the container into classes that are part of your composition root; part of the infrastructure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.