Unity register generic type for non generic interface
.net, c#, generics, unity-container
Solution
If you don't need to resolve using the uncontrolled interface, you can make your own controlled interface which uses generics and derives from the uncontrolled interface. Then you can register the open generic and resolve the closed generic types.
public interface IControlled<T> : IUncontrolled {}
public class Controlled<T> : IControlled<T> {}
container.RegisterType(typeof(IControlled<>), typeof(Controlled<>));
IUncontrolled instance = container.Resolve<IControlled<string>>();
Problem
my scenario looks (to me) very straight forward, but I couldn't find a resolution. I have this scenario ``` public class Class<T> : IInterface where T : class { } ``` the interface cannot be made generic (coming from WCF lib.) so I want to register the interface like this ``` container.RegisterType(typeof (IInterface ), typeof (Class<>)); ``` and then resolve it with T How can I do it? What am I missing? my intention is doing something like ``` container.Resolve<IInterface>(/* specify T */); ```