Final 2.0 Source posted to source control

Apr 15, 2010 at 6:09 PM

Hey everyone. We've hit an unfortunate snag on the release paperwork which means that the final release for Unity 2.0 will be delayed until early next week. However, the code is done (unless somebody finds something seriously disastrous in the next day). So, to whet your appetite I've uploaded the final sources for Unity 2.0 into Codeplex source control. Have at it!

 

Apr 19, 2010 at 5:35 AM
Edited Apr 19, 2010 at 11:52 AM

Any chance you can also post the chm as well, i'm struggling to convert the config file

Apr 19, 2010 at 10:46 PM

I'm in the middle of rewriting that section, actually. What we have now would actually hurt your efforts rather than help. It's coming, trust me. :-)

 

Apr 20, 2010 at 6:19 PM
Edited Apr 20, 2010 at 6:20 PM

Hello,

I think the ResolveAll<> method isn't working.

For instance, in the following code the ResolveAll<> method doesn't return anything, but the Return<> does:

 

namespace UnityTest
{
    class Program
    {
        interface IEmployee
        {
            void Print();
        }

        class RegularEmployee : IEmployee
        {

            #region IEmployee Members

            public void Print()
            {
                Console.WriteLine("I'm a regular");
            }

            #endregion
        }

        class Manager : IEmployee
        {

            #region IEmployee Members

            public void Print()
            {
                Console.WriteLine("I'm the manager");
            }

            #endregion
        }

        static void Main(string[] args)
        {
            IUnityContainer container = new UnityContainer();

            container.RegisterType<IEmployee, RegularEmployee>().RegisterType<IEmployee, Manager>();

            Console.WriteLine("Employees");
            foreach (IEmployee emp in container.ResolveAll(typeof(IEmployee)).ToList())
            {
                emp.Print();
            }

            Console.ReadLine();
        }
    }
}

 

Am I doing something wrong? Or is this a bug? have tried the same example in Autofac and it works (with the necessary changes, of course).

var builder = new ContainerBuilder();
builder.RegisterType<RegularEmployee>().As<IEmployee>();
builder.RegisterType<Manager>().As<IEmployee>();

var container = builder.Build();
foreach (IEmployee emp in container.Resolve<IEnumerable<IEmployee>>())

Regards,
Daniel

Apr 20, 2010 at 6:49 PM

ResolveAll methods return named registrations. You registered an unnamed registration for IEmployee, and then then registered another unnamed IEmployee, which overwrote the first one.

Change your register call to something like:

container.RegisterType<IEmployee, RegularEmployee>("regular")

    .RegisterType<IEmployee, Manager>("manager");

and you'll get your instances back.

 

Apr 20, 2010 at 7:14 PM

Yep, that worked. Thank you.

I should of RTFM first and not just browsed through it :)

Apr 27, 2010 at 1:10 AM

Hi Chris and co....

I noticed that EntLib 5.0 has dropped and it contains Unity 2.0

What changeset is this version based on, and when is the stand alone Unity 2.0 version going to be available ?

 

Cheers...

Rob

Apr 27, 2010 at 5:58 AM

Entlib 5.0 contains the final Unity bits. This matches changeset 50871. When we release the stand alone Unity 2.0 that installer will include the exact same binaries as are in Entlib 5.

We're holding the Unity 2.0 standalone release pending the docs being finished. We figured we could go ahead with the Entlib release because everything else was done except for the Unity docs. They're in final polish & edit now to my understanding, so hopefully not too much longer - I hope by early next week.