Update AddSignalRCore to respect user registered services (#2434)

This commit is contained in:
Mikael Mengistu 2018-06-07 16:32:37 -07:00 committed by BrennanConroy
parent 6c0770398d
commit fa702ff6ef
1 changed files with 9 additions and 8 deletions

View File

@ -3,6 +3,7 @@
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.SignalR.Internal; using Microsoft.AspNetCore.SignalR.Internal;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection namespace Microsoft.Extensions.DependencyInjection
{ {
@ -20,14 +21,14 @@ namespace Microsoft.Extensions.DependencyInjection
public static ISignalRServerBuilder AddSignalRCore(this IServiceCollection services) public static ISignalRServerBuilder AddSignalRCore(this IServiceCollection services)
{ {
services.AddSingleton<SignalRCoreMarkerService>(); services.AddSingleton<SignalRCoreMarkerService>();
services.AddSingleton(typeof(HubLifetimeManager<>), typeof(DefaultHubLifetimeManager<>)); services.TryAddSingleton(typeof(HubLifetimeManager<>), typeof(DefaultHubLifetimeManager<>));
services.AddSingleton(typeof(IHubProtocolResolver), typeof(DefaultHubProtocolResolver)); services.TryAddSingleton(typeof(IHubProtocolResolver), typeof(DefaultHubProtocolResolver));
services.AddSingleton(typeof(IHubContext<>), typeof(HubContext<>)); services.TryAddSingleton(typeof(IHubContext<>), typeof(HubContext<>));
services.AddSingleton(typeof(IHubContext<,>), typeof(HubContext<,>)); services.TryAddSingleton(typeof(IHubContext<,>), typeof(HubContext<,>));
services.AddSingleton(typeof(HubConnectionHandler<>), typeof(HubConnectionHandler<>)); services.TryAddSingleton(typeof(HubConnectionHandler<>), typeof(HubConnectionHandler<>));
services.AddSingleton(typeof(IUserIdProvider), typeof(DefaultUserIdProvider)); services.TryAddSingleton(typeof(IUserIdProvider), typeof(DefaultUserIdProvider));
services.AddSingleton(typeof(HubDispatcher<>), typeof(DefaultHubDispatcher<>)); services.TryAddSingleton(typeof(HubDispatcher<>), typeof(DefaultHubDispatcher<>));
services.AddScoped(typeof(IHubActivator<>), typeof(DefaultHubActivator<>)); services.TryAddScoped(typeof(IHubActivator<>), typeof(DefaultHubActivator<>));
services.AddAuthorization(); services.AddAuthorization();
var builder = new SignalRServerBuilder(services); var builder = new SignalRServerBuilder(services);