public TypedHandlerMiddleware( IDependencyResolver dependencyResolver, TypedHandlerConfiguration configuration) { this.dependencyResolver = dependencyResolver; this.configuration = configuration; }
public TypedHandlerConfiguration Build() { var configuration = new TypedHandlerConfiguration(); foreach (var handlerType in this.handlers) { this.dependencyConfigurator.Add( handlerType, handlerType, this.serviceLifetime); var messageTypes = handlerType .GetInterfaces() .Where(x => x.IsGenericType && typeof(IMessageHandler).IsAssignableFrom(x)) .Select(x => x.GenericTypeArguments[0]); foreach (var messageType in messageTypes) { configuration.HandlerMapping.AddMapping(messageType, handlerType); } } return(configuration); }