Hi

I am using Unity and want to map my handler classes to the query definitions they handle e.g.:-


vb.net Code:
  1. Public Shared Sub RegisterTypes(container As IUnityContainer)
  2.  
  3.         Dim interfaceType As Type = Nothing
  4.  
  5.         'Get the interface definition for the generic query handler interface we are looking for
  6.         interfaceType = GetType(IQueryHandler(Of ,))
  7.  
  8.         container.RegisterTypes(AllClasses.FromAssembliesInBasePath(includeUnityAssemblies:=False, includeSystemAssemblies:=False).Where(Function(t) t.ImplementsInterface(interfaceType)),
  9.                                getFromTypes:=Function() WithMappings.FromMatchingInterface(interfaceType),
  10.                                getName:=Function(i) WithName.TypeName(i),
  11.                                getLifetimeManager:=Function(i) WithLifetime.PerThread(i))


So - how do I register it so that when I pass in a class it can find the appropriate class that implements IQueryHandler of that class?

e.g. if I pass in:-

vb.net Code:
  1. <DataContract>
  2.     Public Class GetServerDateTimeQueryDefinition
  3.         Inherits QueryDefinitionBase(Of DateTime)

How do I get it to return:-

vb.net Code:
  1. Public Class GetServerDateTimeQueryHandler
  2.         Implements IQueryHandler(Of Query.Definitions.GetServerDateTimeQueryDefinition, DateTime)

Any ideas/links?