public static IClientWebSocketBuilder AddClientWebSocket <TClient, TImplementation>(this IServiceCollection services, string name, Func <ClientWebSocket, IServiceProvider, TImplementation> factory)
            where TClient : class
            where TImplementation : class, TClient
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

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

            AddClientWebSocket(services);
            var builder = new DefaultClientWebSocketBuilder(services, name);

            builder.AddTypedWebSocket <TClient>(factory);
            return(builder);
        }
        public static IClientWebSocketBuilder AddClientWebSocket <TClient, TImplementation>(this IServiceCollection services, string name, Action <IServiceProvider, ClientWebSocket> configure)
            where TClient : class
            where TImplementation : class, TClient
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

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

            AddClientWebSocket(services);
            var builder = new DefaultClientWebSocketBuilder(services, name);

            builder.ConfigureClientWebSocket(configure);
            builder.AddTypedWebSocketCore <TClient, TImplementation>(validateSingleType: false);
            return(builder);
        }
        public static IClientWebSocketBuilder AddClientWebSocket <TClient>(this IServiceCollection services)
            where TClient : class
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            AddClientWebSocket(services);

            string name    = TypeNameHelper.GetTypeDisplayName(typeof(TClient), fullName: false);
            var    builder = new DefaultClientWebSocketBuilder(services, name);

            builder.AddTypedWebSocketCore <TClient>(validateSingleType: true);
            return(builder);
        }
        public static IClientWebSocketBuilder AddClientWebSocket <TClient>(this IServiceCollection services, string name)
            where TClient : class
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

            AddClientWebSocket(services);

            var builder = new DefaultClientWebSocketBuilder(services, name);

            builder.AddTypedWebSocketCore <TClient>(validateSingleType: false);
            return(builder);
        }
        public static IClientWebSocketBuilder AddClientWebSocket(this IServiceCollection services, string name, Action <IServiceProvider, ClientWebSocket> configure)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

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

            AddClientWebSocket(services);

            var builder = new DefaultClientWebSocketBuilder(services, name);

            builder.ConfigureClientWebSocket(configure);
            return(builder);
        }