CQRSalad.Dispatching.ServiceProviderExtensions.GetMessageHandler C# (CSharp) Method

GetMessageHandler() static private method

static private GetMessageHandler ( this serviceProvider, Type handlerType ) : object
serviceProvider this
handlerType System.Type
return object
        internal static object GetMessageHandler(this IServiceProvider serviceProvider, Type handlerType)
        {
            object handlerInstance;
            try
            {
                handlerInstance = serviceProvider.GetService(handlerType);
            }
            catch (Exception exception)
            {
                throw new ServiceProviderException(exception);
            }

            if (handlerInstance == null)
            {
                throw new ServiceProviderException($"ServiceProvider has returned null for type '{handlerType}'.");
            }

            return handlerInstance;
        }
ServiceProviderExtensions