2
votes

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. - Piotr Perak

1 Answers

2
votes

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.