MSDN is NOT wrong. We specifically added some shortcut parsing rules so that you don't have to enter all the `'s and square brackets in most cases.
I slapped together an example that looks mostly like yours:
public interface IRepository<T> where T: class
{
}
public class GenericRepository<T> : IRepository<T> where T : class
{
}
public class BlogRepository : GenericRepository<Blog>
{
}
public class Blog
{
}
My XML config looks like this:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<namespace name="UnityConfigExample"/>
<assembly name="UnityConfigExample"/>
<container>
<register type="IRepository[]" mapTo="GenericRepository[]" />
<register type="IRepository[Blog]" mapTo="BlogRepository" />
</container>
</unity>
and it just works.
Were you by any chance trying to use an alias for IRepository instead of the namespace / assembly search? I got the following to work as well using aliases:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<alias alias="IRepository" type="UnityConfigExample.IRepository`1, UnityConfigExample" />
<alias alias="GenericRepository" type="UnityConfigExample.GenericRepository`1, UnityConfigExample"/>
<alias alias="BlogRepository" type="UnityConfigExample.BlogRepository, UnityConfigExample"/>
<alias alias="Blog" type="UnityConfigExample.BlogRepository, UnityConfigExample"/>
<container>
<register type="IRepository[]" mapTo="GenericRepository[]" />
<register type="IRepository[Blog]" mapTo="BlogRepository" />
</container>
</unity>
When you specify the type for an alias, you must use the CLR type syntax. Everywhere else you can use the generic shortcut syntax.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…