Thursday, 29 October 2009

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>

Xml config to configure open generic type mapping:

<typeAlias alias="IRepository`1"            
" /> <type type="IRepository`1" mapTo="Questern.ActiveOrderManagementSystem.Data.Repository.LinqRepository`1,
"> <lifetime type="singleton" /> </type>


Thanks to Marceli for helping out with this!!

Friday, 11 December 2009 07:15:43 (GMT Standard Time, UTC+00:00)
vkqacfwz xpjujkuh cwvquffo kkgazefh [URL=]lpqmxnth[/URL]
Comments are closed.