I've been doing some work with the Unity IoC container recently and had to configure some generic types so I thought I'd post some of the examples here so that I'd have some to refer back to more than anything else a blog post tends to be less likely to get lost that an old post-it note.
Xml config to configure mapping for a specific generic type, note the use of [[]] to define the generic type. Inside the square brackets you specify type name and the assembly containing the type. In both example `1 signifies the generic parameter:
<type type="Data.Repository.IRepository`1[[Poco.Address, Poco]], Data.Repository"
mapTo="Data.Repository.LinqRepository`1[[Poco.Address, Poco]], Data.Repository">
<lifetime type="singleton"></lifetime>
</type>
Xml config to configure open generic type mapping:
<typeAlias alias="IRepository`1"
type="Questern.ActiveOrderManagementSystem.Data.Repository.IRepository`1,
Questern.ActiveOrderManagementSystem.Data.Repository" />
<type type="IRepository`1"
mapTo="Questern.ActiveOrderManagementSystem.Data.Repository.LinqRepository`1,
Questern.ActiveOrderManagementSystem.Data.Repository">
<lifetime type="singleton" />
</type>
Thanks to Marceli for helping out with this!!