Exemple #1
0
        public async Task RouteNotification(IHandlerDescriptor handler, Notification notification)
        {
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                var context = scope.ServiceProvider.GetRequiredService <IRequestContext>();
                context.Descriptor = handler;

                object @params = null;
                if (!(handler.Params is null))
                {
                    @params = notification.Params.ToObject(handler.Params, _serializer.JsonSerializer);
                }
                await MediatRHandlers.HandleNotification(scope.ServiceProvider.GetRequiredService <IMediator>(), handler, @params ?? EmptyRequest.Instance, CancellationToken.None).ConfigureAwait(false);
            }
        }