Example #1
0
 internal IEnumerable <RequestHandler <TRequest> > GetHandlers()
 {
     return(new RequestHandlers <TRequest>(
                _registry.Get <TRequest>()
                .Select(handlerType => _handlerFactory.Create(handlerType))
                .Cast <IHandleRequests <TRequest> >()));
 }
Example #2
0
        public IHandleRequests <TRequest> CreateRequestHandler()
        {
            var handlerType = _attribute.GetHandlerType().MakeGenericType(_messageType);
            var handler     = (IHandleRequests <TRequest>)_factory.Create(handlerType);

            //Lod the context before the initializer - in case we want to use the context from within the initializer
            handler.Context = _requestContext;
            handler.InitializeFromAttributeParams(_attribute.InitializerParams());
            return(handler);
        }
Example #3
0
        public IHandleRequests <TRequest> CreateRequestHandler()
        {
            var handlerType = _attribute.GetHandlerType().MakeGenericType(_messageType);
            var handler     = (IHandleRequests <TRequest>)_factory.Create(handlerType);

            if (handler is null)
            {
                throw new ConfigurationException($"Could not create handler {handlerType} from {_factory}");
            }
            //Load the context before the initializer - in case we want to use the context from within the initializer
            handler.Context = _requestContext;
            handler.InitializeFromAttributeParams(_attribute.InitializerParams());
            return(handler);
        }