I have an interface that has 2 generic parameters.

IStorage<TEntity, TKey> 

And a class that implements the interface

 SqlStorage<TEntity, TKey> 

How to register them in Unity Container? It is written on msdn to do this:

 container.RegisterType( typeof(IStorage<>), typeof(SqlStorage<>), new ContainerLifeTimeManager(), new InjectionConstructor( new object[] { new GenericParameter("TEntity"), new GenericParameter("TKey") })); 

But, VS swears at the wrong amount of parameters in typeof (IStorage <>) and typeof (Storage <>).

What am I doing wrong and right?

    1 answer 1

    You have an interface and the type that implements it has two parameter types, respectively, you need to write like this:

     uc.RegisterType(typeof (IStorage<,>), typeof (SqlStorage<,>));