private (Type handlerType, IQueryHandler handler) ResolveHandler(Type queryType) { _logger.DebugFormat("Looking up handler type in handler registry..."); var handlerType = _handlerRegistry.Get(queryType); if (handlerType == null) { throw new MissingHandlerException($"No handler registered for query: {queryType.FullName}"); } _logger.DebugFormat("Found handler type for {QueryType} in handler registry: {HandlerType}", queryType.Name, handlerType.Name); _logger.Debug("Resolving handler instance..."); var handler = _handlerFactory.Create(handlerType); if (handler == null) { throw new MissingHandlerException($"Handler could not be created for type: {handlerType.FullName}"); } return(handlerType, handler); }
private Tuple <Type, dynamic> ResolveHandler(Type requestType) { _logger.DebugFormat("Looking up handler type in handler registry..."); var handlerType = _handlerRegistry.Get(requestType); if (handlerType == null) { throw new MissingHandlerException($"No handler registered for query: {requestType.FullName}"); } _logger.DebugFormat("Found handler type for {RequestType} in handler registry: {HandlerType}", requestType.Name, handlerType.Name); _logger.Debug("Resolving handler instance..."); var handler = _handlerFactory.Create <dynamic>(handlerType); if (handler == null) { throw new MissingHandlerException($"Handler could not be created for type: {handlerType.FullName}"); } _logger.Debug("Resolved handler instance"); return(new Tuple <Type, dynamic>(handlerType, handler)); }