Quick Unity Questions

Topics: General discussion
Aug 8, 2011 at 3:40 PM

Hi 

I have some very quick Unity questions. I am implementing a very basic scenario where I am passing in the interface implementation to a Service class. 

 

MyService service = new MyService(myContainer.Resolve<ITestRepository>());

I have the code working however, I have to ensure that the myContainer is initialised with the values loaded from the config file. Now I can understand that I can use the singleton pattern here and always return an initalised instance of the container.

Is that the best way? Do I have to keep a reference of the UnityContainer and always use that? 

Finally, I read somewhere that if the pluggable architecture is not required then it is best to register the types in code. Is that correct? Is loading from the config that slow?

 

Thanks

Amar

Aug 8, 2011 at 4:09 PM

Hi,

To get a better answer, you must post this to Unity Forum (http://unity.codeplex.com/discussions)

Aug 8, 2011 at 4:14 PM

Thanks, I couldn't find that forum before. Will post there.