private void AddHandler(Type interfaceType, MethodInfo method, Type invokePayloadType, Type returnPayloadType, FilterChain filterChain, bool isSyncHandler, bool isReentrant)
{
if (method.IsGenericMethod == false)
{
if (isSyncHandler)
{
_table.Add(invokePayloadType, new RequestHandlerItem
{
InterfaceType = interfaceType,
IsReentrant = isReentrant,
Handler = BuildHandler(_type, invokePayloadType, returnPayloadType, method, filterChain)
});
}
else
{
_table.Add(invokePayloadType, new RequestHandlerItem
{
InterfaceType = interfaceType,
IsReentrant = isReentrant,
AsyncHandler = BuildAsyncHandler(_type, invokePayloadType, returnPayloadType, method, filterChain)
});
}
}
else
{
// because a generic method needs parameter types to construct handler
// so factory method is built to generate the handler when paramter types are ready
if (isSyncHandler)
{
_table.Add(invokePayloadType, new RequestHandlerItem
{
InterfaceType = interfaceType,
IsReentrant = isReentrant,
IsGeneric = true,
GenericHandlerBuilder = t => new RequestHandlerItem
{
InterfaceType = interfaceType,
IsReentrant = isReentrant,
Handler = BuildGenericHandler(_type, t, returnPayloadType, method, filterChain)
}
});
}
else
{
_table.Add(invokePayloadType, new RequestHandlerItem
{
InterfaceType = interfaceType,
IsReentrant = isReentrant,
IsGeneric = true,
GenericHandlerBuilder = t => new RequestHandlerItem
{
InterfaceType = interfaceType,
IsReentrant = isReentrant,
AsyncHandler = BuildGenericAsyncHandler(_type, t, returnPayloadType, method, filterChain)
}
});
}
}
}