Exemplo n.º 1
0
        public static IApplicationBuilder UseServerSentEvents(this IApplicationBuilder app, ServerSentEventsService serverSentEventsService)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (serverSentEventsService == null)
            {
                throw new ArgumentNullException(nameof(serverSentEventsService));
            }

            Type serverSentEventsServiceType    = serverSentEventsService.GetType();
            Type serverSentEventsMiddlewareType = typeof(ServerSentEventsMiddleware <>).MakeGenericType(serverSentEventsServiceType);

            return(app.UseMiddleware(serverSentEventsMiddlewareType));
        }