container.register - how to find instanciation of objects

Dec 6, 2010 at 7:31 PM

Hi, This is my firt post on this forum. Hopefully I have fulfiled the guidelines for posting. Did a search and didn't find anything.

I am working on this new project. They are using MVVM/WPF/Prism.

I have a hard time instanciating objects. I have downloaded and finished all the exercices about Unit here,

but I still don't know how objects are beeing instanciated. Currently I "see" container.registertype as registering the type. But no "values" are passed. 

Now in this project there is something similar to this:


Public Sub New(ByVal view As IView, _
 ByVal container As IUnityContainer, _
 ByVal rM As IRM, _
 ByVal DSet As DataSet, _ 
 ByVal searchService As Services.ISearchService,  ByVal eventAggregator As IEventAggregator)

There is no direct call to the New() function in the solution.
Did a "Find" for "New SearchNavigationViewModel(" and it returns nothing

Instead I am told that the "Container" replaces this.
I do a search for "SearchViewModel" and I look for results with "Container" in it.

I get the following results:

SearchModule.vb(75):  Me._container.RegisterType(Of ISearchNavigationViewModel, SearchNavigationViewModel)(New ContainerControlledLifetimeManager())
SearchViewModel.vb(60): Me.SearchNavigationViewModel = _container.Resolve(Of ISearchNavigationViewModel)()

I see a "Register" and I see a "Resolve". I don't see any of those passing the mandatory parameters of the New.

Maybe it's because the _container is passed as a parameter in the New() of SearchModule. Maybe it's done previously.

Do a search for "SearchModule" and I look for results with "Container" or "New SearchModule(" in it. I get results but I don't see a new or a container.

What do I do now ?

Is there a way I can find out who instanciates " SearchNavigationViewModel.vb" ? What are the advantages of using the "Unity Container" instead of calling the New directly ?

What is the purpose of passing datatypes instead of passing the actual value required as a parameter in the New() ? I am not convinced about this "container" thing it's a tomato tom-ato thing if you ask me. both are the same but one is "straight-forward"

I think I need to be enlightened because I doubt that there are no advantages to this container.registertype thingy....


Dec 7, 2010 at 6:02 PM

I found my answer. I understood DeplendencyInjection. I didn't understand it in the context of the application.