Generic Open Type

Mar 19, 2008 at 3:35 PM
Edited Mar 19, 2008 at 5:22 PM
Funny how some things you don't discover until far in the process...

I just figured out Unity doesn't support open type mapping like OB2 used to:

public interface IFoo<T> { ... }
public class Foo<T> : IFoo<T> { ... }
container.Register(typeof(IFoo<>), typeof(Foo<>));
IFoo<int> foo = container.Resolve<IFoo<int>>();

I get an ArgumentException in Guard.TypeIsAssignableFrom.

I said to myself, fine, I'll override UnityContainer.RegisterType(Type from, Type to, LifetimeManager manager) so I change the check to the Guard condition but then, I won't be able to raise the registering event.

Am stuck!
Mar 19, 2008 at 6:29 PM
The existing OB2 support didn't work if your build key wasn't a type, like just about all the rest of OB2. I took it out because I had higher priority things to get working first.

I started work on this again yesterday, hope to have it working for the next drop.
Mar 24, 2008 at 3:15 PM
I have exactly the same problem. Any idea when the next drop will be released?

Mar 24, 2008 at 10:10 PM
Just posted the new drop about 3 minutes ago. Have at it!