Unity 1.2 Container Hierarchy and ResolveAll strange combination

Aug 10, 2009 at 10:26 PM

Hi!

I've used the ResolveAll method on the child of the container hierarchy and received some strange result. Here is the short sample:

 

            IUnityContainer container = new UnityContainer();
            container.RegisterInstance("str1", "string1");
            container.RegisterInstance("str2", "string2");
             
            IUnityContainer child = container.CreateChildContainer();
            child.RegisterInstance("str2", "string20");
            child.RegisterInstance("str3", "string30");
            var strlist = child.ResolveAll<string>();
            foreach (string s in strlist)
            {
                Console.WriteLine(s);
            }


This code shows the next result:
string1
string20
string20
string30

As for me, this is strange behaviour. I expected to receive the sequence
string1
string20
string30

The question is: is it possible to receive the values from child container for all instances, whose names are used in the child container, and values from parent container for all instances, whose names are not used in the child container?

 

 
Oct 28, 2009 at 7:51 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.