internal LanguageClient(LanguageClientOptions options) : base(options)
        {
            _capabilities       = options.SupportedCapabilities;
            _clientCapabilities = options.ClientCapabilities;
            var services = options.Services;

            services.AddLogging(builder => options.LoggingBuilderAction(builder));
            options.RequestProcessIdentifier ??= (options.SupportsContentModified
                ? new RequestProcessIdentifier(RequestProcessType.Parallel)
                : new RequestProcessIdentifier(RequestProcessType.Serial));
            // services.AddSingleton<IOptionsMonitor<LoggerFilterOptions>, LanguageClientLoggerFilterOptions>();

            _clientInfo = options.ClientInfo;
            _receiver   = options.Receiver;
            var serializer            = options.Serializer;
            var supportedCapabilities = new SupportedCapabilities();

            _textDocumentIdentifiers = new TextDocumentIdentifiers();
            var collection = new SharedHandlerCollection(supportedCapabilities, _textDocumentIdentifiers);

            services.AddSingleton <IHandlersManager>(collection);
            _collection = collection;
            // _initializeDelegates = initializeDelegates;
            // _initializedDelegates = initializedDelegates;
            _startedDelegates      = options.StartedDelegates;
            _rootUri               = options.RootUri;
            _trace                 = options.Trace;
            _initializationOptions = options.InitializationOptions;

            services.AddSingleton <IOutputHandler>(_ =>
                                                   new OutputHandler(options.Output, options.Serializer, options.Receiver.ShouldFilterOutput, _.GetService <ILogger <OutputHandler> >()));
            services.AddSingleton(_collection);
            services.AddSingleton(_textDocumentIdentifiers);
            services.AddSingleton(serializer);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.ISerializer>(serializer);
            services.AddSingleton(options.RequestProcessIdentifier);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.IReceiver>(options.Receiver);
            services.AddSingleton(options.Receiver);
            services.AddSingleton <ILanguageClient>(this);
            services.AddSingleton <LspRequestRouter>();
            services.AddSingleton <IRequestRouter <ILspHandlerDescriptor> >(_ => _.GetRequiredService <LspRequestRouter>());
            services.AddSingleton <IRequestRouter <IHandlerDescriptor> >(_ => _.GetRequiredService <LspRequestRouter>());
            services.AddSingleton <IResponseRouter, ResponseRouter>();

            services.AddSingleton <IProgressManager, ProgressManager>();
            services.AddSingleton(_ => _.GetRequiredService <IProgressManager>() as IJsonRpcHandler);
            services.AddSingleton <IClientWorkDoneManager, ClientWorkDoneManager>();
            services.AddSingleton(_ => _.GetRequiredService <IClientWorkDoneManager>() as IJsonRpcHandler);

            EnsureAllHandlersAreRegistered();

            services.AddSingleton <RegistrationManager>();
            services.AddSingleton <IRegistrationManager>(_ => _.GetRequiredService <RegistrationManager>());
            if (options.DynamicRegistration)
            {
                services.AddSingleton(_ => _.GetRequiredService <RegistrationManager>() as IJsonRpcHandler);
            }

            var workspaceFoldersManager = new WorkspaceFoldersManager(this);

            services.AddSingleton(workspaceFoldersManager);
            services.AddSingleton <IWorkspaceFoldersManager>(workspaceFoldersManager);
            if (options.WorkspaceFolders)
            {
                services.AddSingleton <IJsonRpcHandler>(workspaceFoldersManager);
            }

            var serviceProvider = services.BuildServiceProvider();

            _disposable.Add(serviceProvider);
            _serviceProvider = serviceProvider;
            collection.SetServiceProvider(_serviceProvider);

            _responseRouter          = _serviceProvider.GetRequiredService <IResponseRouter>();
            _progressManager         = _serviceProvider.GetRequiredService <IProgressManager>();
            _workDoneManager         = _serviceProvider.GetRequiredService <IClientWorkDoneManager>();
            _registrationManager     = _serviceProvider.GetRequiredService <RegistrationManager>();
            _workspaceFoldersManager = _serviceProvider.GetRequiredService <IWorkspaceFoldersManager>();

            _connection = new Connection(
                options.Input,
                _serviceProvider.GetRequiredService <IOutputHandler>(),
                options.Receiver,
                options.RequestProcessIdentifier,
                _serviceProvider.GetRequiredService <IRequestRouter <IHandlerDescriptor> >(),
                _responseRouter,
                _serviceProvider.GetRequiredService <ILoggerFactory>(),
                options.OnUnhandledException ?? (e => { }),
                options.CreateResponseException,
                options.MaximumRequestTimeout,
                options.SupportsContentModified,
                options.Concurrency
                );

            // We need to at least create Window here in case any handler does loggin in their constructor
            TextDocument = new TextDocumentLanguageClient(this, _serviceProvider);
            Client       = new ClientLanguageClient(this, _serviceProvider);
            General      = new GeneralLanguageClient(this, _serviceProvider);
            Window       = new WindowLanguageClient(this, _serviceProvider);
            Workspace    = new WorkspaceLanguageClient(this, _serviceProvider);

            workspaceFoldersManager.Add(options.Folders);

            var serviceHandlers    = _serviceProvider.GetServices <IJsonRpcHandler>().ToArray();
            var serviceIdentifiers = _serviceProvider.GetServices <ITextDocumentIdentifier>().ToArray();

            _disposable.Add(_textDocumentIdentifiers.Add(serviceIdentifiers));
            _disposable.Add(_collection.Add(serviceHandlers));
            options.AddLinks(_collection);
        }
        internal LanguageServer(LanguageServerOptions options) : base(options)
        {
            var services = options.Services;
            var configurationProvider = new DidChangeConfigurationProvider(this, options.ConfigurationBuilderAction);

            services.AddSingleton <IJsonRpcHandler>(configurationProvider);
            options.RequestProcessIdentifier ??= (options.SupportsContentModified
                ? new RequestProcessIdentifier(RequestProcessType.Parallel)
                : new RequestProcessIdentifier(RequestProcessType.Serial));

            services.AddSingleton <IConfiguration>(configurationProvider);
            services.AddSingleton(Configuration = configurationProvider);

            services.AddLogging(builder => options.LoggingBuilderAction(builder));
            services.AddSingleton <IOptionsMonitor <LoggerFilterOptions>, LanguageServerLoggerFilterOptions>();

            _serverInfo              = options.ServerInfo;
            _serverReceiver          = options.Receiver;
            _serializer              = options.Serializer;
            _supportedCapabilities   = new SupportedCapabilities();
            _textDocumentIdentifiers = new TextDocumentIdentifiers();
            var collection = new SharedHandlerCollection(_supportedCapabilities, _textDocumentIdentifiers);

            services.AddSingleton <IHandlersManager>(collection);
            _collection           = collection;
            _initializeDelegates  = options.InitializeDelegates;
            _initializedDelegates = options.InitializedDelegates;
            _startedDelegates     = options.StartedDelegates;

            services.AddSingleton <IOutputHandler>(_ => new OutputHandler(
                                                       options.Output,
                                                       options.Serializer,
                                                       options.Receiver.ShouldFilterOutput,
                                                       _.GetService <ILogger <OutputHandler> >())
                                                   );
            services.AddSingleton(_collection);
            services.AddSingleton(_textDocumentIdentifiers);
            services.AddSingleton(_serializer);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.ISerializer>(_serializer);
            services.AddSingleton(options.RequestProcessIdentifier);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.IReceiver>(options.Receiver);
            services.AddSingleton <ILspServerReceiver>(options.Receiver);

            services.AddTransient <IHandlerMatcher, TextDocumentMatcher>();
            services.AddSingleton <ILanguageServer>(this);
            services.AddTransient <IHandlerMatcher, ExecuteCommandMatcher>();
            services.AddTransient <IHandlerMatcher, ResolveCommandMatcher>();
            services.AddSingleton <LspRequestRouter>();
            services.AddSingleton <IRequestRouter <ILspHandlerDescriptor> >(_ => _.GetRequiredService <LspRequestRouter>());
            services.AddSingleton <IRequestRouter <IHandlerDescriptor> >(_ => _.GetRequiredService <LspRequestRouter>());
            services.AddSingleton <IResponseRouter, ResponseRouter>();
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(ResolveCommandPipeline <,>));

            services.AddSingleton <IProgressManager, ProgressManager>();
            services.AddSingleton <IJsonRpcHandler>(_ => _.GetRequiredService <IProgressManager>() as IJsonRpcHandler);
            services.AddSingleton <IServerWorkDoneManager, ServerWorkDoneManager>();
            services.AddSingleton <IJsonRpcHandler>(_ => _.GetRequiredService <IServerWorkDoneManager>() as IJsonRpcHandler);

            EnsureAllHandlersAreRegistered();

            var serviceProvider = services.BuildServiceProvider();

            _disposable.Add(serviceProvider);
            _serviceProvider = serviceProvider;
            collection.SetServiceProvider(_serviceProvider);

            var requestRouter = _serviceProvider.GetRequiredService <IRequestRouter <ILspHandlerDescriptor> >();

            _responseRouter        = _serviceProvider.GetRequiredService <IResponseRouter>();
            ProgressManager        = _serviceProvider.GetRequiredService <IProgressManager>();
            _serverWorkDoneManager = _serviceProvider.GetRequiredService <IServerWorkDoneManager>();
            _connection            = new Connection(
                options.Input,
                _serviceProvider.GetRequiredService <IOutputHandler>(),
                options.Receiver,
                options.RequestProcessIdentifier,
                _serviceProvider.GetRequiredService <IRequestRouter <IHandlerDescriptor> >(),
                _responseRouter,
                _serviceProvider.GetRequiredService <ILoggerFactory>(),
                options.OnUnhandledException ?? (e => { ForcefulShutdown(); }),
                options.CreateResponseException,
                options.MaximumRequestTimeout,
                options.SupportsContentModified,
                options.Concurrency
                );

            // We need to at least create Window here in case any handler does loggin in their constructor
            TextDocument = new TextDocumentLanguageServer(this, _serviceProvider);
            Client       = new ClientLanguageServer(this, _serviceProvider);
            General      = new GeneralLanguageServer(this, _serviceProvider);
            Window       = new WindowLanguageServer(this, _serviceProvider);
            Workspace    = new WorkspaceLanguageServer(this, _serviceProvider);

            _disposable.Add(_collection.Add(this));

            {
                var serviceHandlers    = _serviceProvider.GetServices <IJsonRpcHandler>().ToArray();
                var serviceIdentifiers = _serviceProvider.GetServices <ITextDocumentIdentifier>().ToArray();
                _disposable.Add(_textDocumentIdentifiers.Add(serviceIdentifiers));
                _disposable.Add(_collection.Add(serviceHandlers));
                options.AddLinks(_collection);
            }
        }