using System; using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR.Internal.Protocol; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection { public static class JsonProtocolDependencyInjectionExtensions { /// /// Enables the JSON protocol for SignalR. /// /// /// This has no effect if the JSON protocol has already been enabled. /// /// The representing the SignalR server to add JSON protocol support to. /// The value of public static ISignalRBuilder AddJsonProtocol(this ISignalRBuilder builder) => AddJsonProtocol(builder, _ => { }); /// /// Enables the JSON protocol for SignalR and allows options for the JSON protocol to be configured. /// /// /// Any options configured here will be applied, even if the JSON protocol has already been registered with the server. /// /// The representing the SignalR server to add JSON protocol support to. /// A delegate that can be used to configure the /// The value of public static ISignalRBuilder AddJsonProtocol(this ISignalRBuilder builder, Action configure) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); builder.Services.Configure(configure); return builder; } } }