// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection { /// /// Extension methods for . /// public static class SignalRDependencyInjectionExtensions { /// /// Adds the minimum essential SignalR services to the specified . Additional services /// must be added separately using the returned from this method. /// /// The to add services to. /// An that can be used to further configure the SignalR services. public static ISignalRServerBuilder AddSignalRCore(this IServiceCollection services) { services.TryAddSingleton(); services.TryAddSingleton(typeof(HubLifetimeManager<>), typeof(DefaultHubLifetimeManager<>)); services.TryAddSingleton(typeof(IHubProtocolResolver), typeof(DefaultHubProtocolResolver)); services.TryAddSingleton(typeof(IHubContext<>), typeof(HubContext<>)); services.TryAddSingleton(typeof(IHubContext<,>), typeof(HubContext<,>)); services.TryAddSingleton(typeof(HubConnectionHandler<>), typeof(HubConnectionHandler<>)); services.TryAddSingleton(typeof(IUserIdProvider), typeof(DefaultUserIdProvider)); services.TryAddSingleton(typeof(HubDispatcher<>), typeof(DefaultHubDispatcher<>)); services.TryAddScoped(typeof(IHubActivator<>), typeof(DefaultHubActivator<>)); services.AddAuthorization(); var builder = new SignalRServerBuilder(services); builder.AddJsonProtocol(); return builder; } } }