Hi
I am using Unity and want to map my handler classes to the query definitions they handle e.g.:-
vb.net Code:
Public Shared Sub RegisterTypes(container As IUnityContainer) Dim interfaceType As Type = Nothing 'Get the interface definition for the generic query handler interface we are looking for interfaceType = GetType(IQueryHandler(Of ,)) container.RegisterTypes(AllClasses.FromAssembliesInBasePath(includeUnityAssemblies:=False, includeSystemAssemblies:=False).Where(Function(t) t.ImplementsInterface(interfaceType)), getFromTypes:=Function() WithMappings.FromMatchingInterface(interfaceType), getName:=Function(i) WithName.TypeName(i), 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:
<DataContract> Public Class GetServerDateTimeQueryDefinition Inherits QueryDefinitionBase(Of DateTime)
How do I get it to return:-
vb.net Code:
Public Class GetServerDateTimeQueryHandler Implements IQueryHandler(Of Query.Definitions.GetServerDateTimeQueryDefinition, DateTime)
Any ideas/links?




Reply With Quote
