Generics in config file

Apr 21, 2008 at 3: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 6:31 AM
Edited Apr 21, 2008 at 6: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 11:07 AM
Apr 21, 2008 at 5: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.