Unity 2 - Changed RegisterType- and Resolve-Method

May 21, 2010 at 10:28 AM

Hello p&p-Team,

 

i would like use the new Unity 2 and have a problem with the new RegisterType- and Resolve-Method. 

I like use only this code: .RegisterType(typeof(IFoo), typeof(Foo));
and i see the Method has not 2 params.. he like a overload with 5 params... we need not name with string-value and lifetimemanager... we like only 2 params.. i missed the generics solution :(

The same problem is with the Resolve... i like only .Resolve(typeof(IFoo));

Thank you and best Regards,
BFreakout

 
May 21, 2010 at 10:57 AM
Edited May 21, 2010 at 10:58 AM

The overload methods you're looking for are still there.  The RegisterType you will use is the one which takes the parameter Type as its first and second parameter and an optional parameter of array of InjectionMember. 

RegisterType(Type from, Type to, params InjectionMember[] injectionMembers) //the last parameter is optional

For the Resolve method, the overload method is

Resolve(Type t, params ResolverOverride[] overrides) //again, the second parameter is optional

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 21, 2010 at 11:16 AM

Hello Sarah,

thank you for the fast answer.. the RegisterType need 5 arguments.. on Resolve work it only with null.. (.Resolve(typeof(IFoo), null))...

Best Regards,
BFreakout

May 21, 2010 at 4:59 PM

All the overloads have been moved to extension methods. Add "using Microsoft.Practices.Unity;" to the top of your source file and the rest of them will show up.

 

May 26, 2010 at 9:39 AM

Thank you.. works..