Generics in config file

Apr 21, 2008 at 2:51 AM

I have a class with a generics dependecy:

public ProductController(IRepository<Product> repository)

How can the generic be entered in the config file?

Apr 21, 2008 at 5:31 AM
Edited Apr 21, 2008 at 5:32 AM


            type="IRepository`1[[Product, ProductAssembly]], RepositoryAssembly"
            mapTo="ProductRepository, MyAssembly"/>
The syntax is bulky, but it makes sense. If you forget, you can look at the "FullName" property of your type:

string typeFullName = typeof(IRepository<Product>).FullName;
Apr 21, 2008 at 10:07 AM
Apr 21, 2008 at 4:41 PM
If you need to use the same generic type multiple times, it'd probably help to use a type alias to give the generic type an easier name.